Search code examples
graphqlcontentful

Contentful, is there a way to filter on entryCollection?


I have this graphql query - I had to reverse it as I had to match/filter on a linkedForm

query LocalState3 {
  localStatePageCollection(where: { seoName: "ca"}, limit:1) {
    items {
      name
      seoName
      url
      linkedFrom {
        entryCollection{
          items {
            ... on LocalCity {
              seoName
              name
            }
          }
        }
      }
    }
  }
}

I will get a bunch of "cities" here - BUT I want to get a specific city UNDER the "ca" state. I know I can filter on the front end, BUT I'd rather do this in graphql if possible?

I thought this might work, but didn't

 entryCollection(where: { seoName: "culver-city"}, limit: 1)
 entryCollection(filter: { seoName: { eq:"culver-city"}}, limit:1)

any way to filter on items or entryCollection or ?


Solution

  • According to Contentful documentation, filtering on link collections is not possible https://www.contentful.com/developers/docs/references/graphql/#/reference/collection-filters/limitations

    It is not possible to filter on fields of Type Array, Object, or RichText. There's an exemption in the case of the ContentfulMetadata type