I'm looking to create a GraphQL query that selectively adds/removes fields based on a variable "type", which is a string:
query ResultsPage($casetype: String!)
According to the reference on Directives, you can use a boolean value to either @include
or @skip
certain fields:
query Hero($episode: Episode, $withFriends: Boolean!) {
hero(episode: $episode) {
name
friends @include(if: $withFriends) {
name
}
}
}
How could I do something similar with this string value? i.e. only include the friends
field if $casetype = "foo"
. Is this possible with GraphQL?
Thanks!