Open YannickB opened 6 years ago
Thanks for reporting this. graphql
shouldn't panic, and I will fix that.
But I suspect I see what the issue is. You're not specifying the exact pointer type for the nil variable. You should do this instead:
err := client.Mutate(context.Background(), createMutation, map[string]interface{}{
"title": githubql.String("test"),
"parentID": (*githubql.ID)(nil),
})
Otherwise, it's not possible for graphql
to know the types of "title" and "parentID" variables when constructing the query. See https://github.com/shurcooL/graphql#arguments-and-variables for more info.
It's true, thanks for the tip!
Hi,
When calling mutate function with a null variables I have the following error :
My receiving struct
type requirementCreateMutation struct {Requirement requirementResult graphql:"createRequirement(title: $title, parentID: $parentID)"}
My variables :
err := client.Mutate(context.Background(), createMutation, map[string]interface{ 'title': 'test', 'parentID': nil, })
My graphql schema :
createRequirement( title: String! parentID: ID)
So it seems the error appears if we try to send a nil value to a non required graphql field. I plan to use different struct if parent is nil as workaround, but imho having a traceback in such case is a bug. Ideally, it should just send a nil value to the graphql server.
Best regards,