ID type intersects poorly with map[string]interface{}.
When you create a variable of type githubql.ID and place it into a map[string]interface{} as part of variables, the fact that its type was githubql.ID gets "lost" because the type is interface{} which satisfies interfaces{}.
This means queryArguments has a hard time telling the original type name:
var nodeID = githubql.ID("someid")
variables := map[string]interface{}{
"id": nodeID,
}
Results in query($nodeID: string!) { ... } instead of query($nodeID: ID!) { ... }.
This breaks it for me when I have query variables of type String! as it converts all strings to ID!
var m struct {
CreateClinicalCodeType struct {
Type graphql.String
Description graphql.String
} `graphql:"createClinicalCodeType(type:$type, description:$description)"`
}
variables := map[string]interface{}{
"type": "TestType",
"description": "Test Description",
}
Results in the mutation string, converting all Strings! to ID!:
mutation($description:ID!$type:ID!){createClinicalCodeType(type:$type, description:$description){type,description}}
@mwilli31 You need to explicitly specify the GraphQL type for variables, like so:
variables := map[string]interface{}{
"type": githubql.String("TestType"),
"description": githubql.String("Test Description"),
}
This is now mentioned in the Arguments and Variables section of the README.
@shurcooL Great! Validated it is working as stated. Thanks!