I'm using the Graphiql Go GUI. I'm trying to create mutation that creates a user. However, I get an error saying that an email has not been provided.
If I view the request, it doesn't include the substituted value. And because of that it doesn't ever make it far enough in the server to create a user.
I'm wondering the proper syntax for this. I've read the docs and several responses from the community and this looks to be the correct syntax.
mutation CreateUser($email: String!) {
createUser(email: $email) {
id
email
}
}
query variables:
{
"email": "test@test.com"
}
type:
var RootMutation = graphql.NewObject(graphql.ObjectConfig{
Name: "RootMutation",
Fields: graphql.Fields{
"createUser": &graphql.Field{
Type: UserType,
Description: "Creates a new user",
Args: graphql.FieldConfigArgument{
"email": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(graphql.String),
},
},
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
email, err := params.Args["email"].(string)
log.Println(err)
log.Println(email)
// handle creating user
},
},
},
})
Error:
{
"data": null,
"errors": [
{
"message": "Variable \"$email\" of required type \"String!\" was not provided.",
"locations": [
{
"line": 1,
"column": 21
}
]
}
]
}
I don't understand why if there are no errors on the client GUI side (graphiql) why it wouldn't be sending along the email to the backend.
Is there something I'm missing?