Customizing a complex Apollo gql query at runtime
Asked Answered
C

0

6

I've been using @skip and @include directives in a couple of my queries and while they work quite good for 'simply' customisable queries I'm looking for a solution supporting a highly customisable query. I'm talking about ~20 fields, each of them skipped/included by it's own individual flag. While passing 20 boolean arguments to the query and using @include(if: $the_flag) 20 times is theoretically possible I'm looking for a better way of doing that. Like passing a configuration object and including some query parts based on it's fields, or maybe merging the query from stitches based on each flag.

I've read about @graphql-tools/stitch but I'm not sure my solution will benefit this approach with ~20 stitches. Is there any tool or any easy way to create a highly customisable query based on multiple conditions on the fly?

Chaldea answered 27/12, 2022 at 20:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.