ExpressionEngine / coilpack-docs

https://expressionengine.github.io/coilpack-docs/
2 stars 2 forks source link

[GRAPHQL] "with" query parameter #5

Open Zignature opened 2 months ago

Zignature commented 2 months ago

How do I use the with parameter in a query? And what is it for? I'm guessing it's a filtering parameter...

query myQuery {
  exp_channel_entries(
    channel: "my_channel",
    with: ???
  ) {
    data {
      ...
    }
  }
}

I'm running coilpack 1.x-dev

bryannielsen commented 2 months ago

@Zignature sorry this isn't in the official docs, a lot of the GraphQL API is meant to be self-documenting through tools like GraphiQL but we should get this in the docs as well.

The with parameter takes A pipe separated list of relationships to eager load. So this is just a parameter to help with performance. If you had the following query then including the with will reduce the number of database queries required to load the Author attributes

exp_channel_entries(with: "author") {
    data {
      author {
        screen_name
      }
    }
  }