[v4] Filter by Component field in GraphQL

System Information
  • Strapi Version: 4.0 (latest master)
  • Operating System:
  • Database: Postgres
  • Node Version: v14.18.0
  • NPM Version: 6.14.15
  • Yarn Version: 1.22.10

I’m unable to use filters on component fields. The following works (state is an enum - fixed in commit e16bf9b259da473f3273ec58048e33f3136de816):

query {
  businesses(filters: {
    state: { eq: "CA" }
  }) {
  	data {
      id
      attributes {
        name
        slug
        state
        location {
          state
          city
        }
      }
    }
  }
}

However if I try to filter on the location > state instead of the enum state, I get

"message": "Field \"location\" is not defined by type \"BusinessFiltersInput\"."

My query is

query {
  businesses(filters: {
    location: { eq: {
      state: { eq: "CA" }
    } }
  }) {
  	data {
      id
      attributes {
        name
        slug
        state
        location {
          state
          city
        }
      }
    }
  }
}

Is this supported or will it be? or should I just flatten the component’s fields into the collection like I did with state?

Thanks,
Brett

2 Likes

Hi, did you find a solution? facing similar issue…