Reputation: 163
I am using the AWS AppSync service as my GraphQL server. I am passing a mutation GraphQL tag to create a user but somehow I am getting this error in the console:
GraphQL error: Variable 'id' has coerced Null value for NonNull type 'ID!'
The mutation GraphQL tag is like this:
import gql from 'graphql-tag';
export default gql`
mutation addUser ($id:ID!,$name:String!,$email:String!,$number:String!,$gender:String!,$password:String!,$createdAt:String!,$type:String!){
addUser(
id:$id,
name:$name,
email:$email,
number:$number,
gender:$gender,
password:$password,
createdAt:$createdAt,
type:$type
){
id
name
email
}
}`;
and I am passing this GraphQL tag inside my SignupForm.js
to create a user like this:
export default graphql(AddUser,{
props:props=>({
AddUser:user=>props.mutate({
variable:user,
})
})
})(SignUpForm);
When I call this.props.AddUser(user)
where user is signup user details object
I got error mentioned above.
Upvotes: 3
Views: 9948
Reputation: 3210
It seems the problem is a typo in the mutation options:
{ variable: user }
should be { variables: user }
(with an 's')
Upvotes: 4