graphql
graphql copied to clipboard
Help: example with directives
Can someone please provide a query example which uses @skip or @include directive?
It's not a small example, but the @include directive is used here.
@dmitshur Thank you for your reply. so here is how i got it to work: using this schema
type Test {
field1 String!
field2 String!
}
type Query{
tests: [Test!]!
}
the struct I used is:
var q struct {
Test []struct {
Field1 graphql.string
IncludeField1 graphql.string `graphql:"@include(if:$f1)"`
Field2 graphql.string
IncludeField2 graphql.string `graphql:"@include(if:$f2)"`
}
}
v := map[string]interface{
"f1": graphql.Boolean(true),
"f2": graphql.Boolean(false),
}
client.Query(context.Background(), &q, v)
I would really appreciate a better solution.