How do you query by a content relationship in a group, but in graphql?

In the REST API, you can filter data by a value in a content relationship in a group, but I can't seem to find how to do so in graphql.

For example, the documentation in REST:

But in graphql, the documentation doesn't mention groups:

I need to be able to filter by service, and I'm not seeing it as an option here:

Please help!

1 Like

Hey again!!

Queries by Content Relationship / Link fields must be top-level fields

When using the Content Relationship or Link field as arguments in GraphQL, they have to be at the top level of a Custom Type. It's not possible to use them as arguments if the field is inside a Group field or a Slice.

Similarly to the REST queries, you need to pass the ID of the doc you're looking for using the where argument along with the API ID of the Content Rel. field. So if that field is called "connection", a query would look something like this:

query {
  allPosts(where : {connection: "XECf-BAAACEACaD9"}) {
    edges {
      node {
        connection {
          ... on Author {
            _meta {
              id
            }
          }
        }
      }
    }
  }
}

We updated the GraphQL docs to make this clearer, thank you very much.

If you need anything else let us know!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.