Closed jorgevillafuerte closed 1 year ago
I tried your mutation, and the output is expected.
var mutation struct {
CreateProducts struct {
Name string
} `graphql:"createProducts(name: $name, url: $url, email: $email, callbackUrl: $callbackUrl)"`
}
variables = map[string]interface{}{
"name": "foo",
"email": "bar",
"callbackUrl": (*string)(nil),
}
mutation ($callbackUrl:String$email:String!$name:String!){
createProducts(name: $name, url: $url, email: $email, callbackUrl: $callbackUrl) {
name
}
}
We have to input the nil
variable because the library needs to infer the variable type and translate it to the equivalent GraphQL type. If you want to build the GraphQL query dynamically yourself, you can use the Exec
method.
thanks! That works. I'm closing the issue
Hello! I'm have this graphql tag
graphql:"createProducts(name: $name, url: $url, callbackUrl: $callbackUrl, email: $email)"
and this variables mapif config.CallbackUrl is empty, the result mutation is this, missing declare $callbackUrl as String
if I change vars maps, adding "callbackUrl" as (*graphql.String)(nil), the variable declaration has the value $callbackUrl as String
but the mutation return this error
"'callbackUrl' must be a string"
There is no way to create a variable in our mutation query and don't send it. Or is no dynamic way to change the graphql tag