Help: example with directives
MShoaei opened this issue · 2 comments
MShoaei commented
Can someone please provide a query example which uses @skip
or @include
directive?
MShoaei commented
@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.