I'm trying to add a user using relay , below is my schema file
schema.graphql
createUser(input: CreateUserInput!): UserPayload
input CreateUserInput {
clientMutationId: String
data: CreateUserData!
}
type CreateUserData {
firstName: String!
lastName: String!
password: String!
email: String
}
type UserPayload {
clientMutationId: String
node: User
}
type User {
id: ID!
firstName: String!
lastName: String!
email: String
password: String
}
below is my mutation file ,
AddUserMutation.js
const mutation = graphql`
mutation AddUserMutation($input: CreateUserInput!) {
createUser(input: $input) {
data {
firstName
lastName
email
password
}
}
}
`;
function commit(environment, node) {
var firstName = node.fName;
var lastName = node.lName;
var email = node.signupEmail;
var password = node.pwd;
return commitMutation(environment, {
mutation,
variables: {
input: {
firstName,
lastName,
email,
password
},
},onCompleted: (response, errors) => {
console.log('Response received from server.',response)
},
onError: err => console.error(err),
},
);
}
export default { commit };
But it is throwing me this error
GraphQLParser: Unknown field
data
on typeUserPayload
. Source: documentAddUserMutation
file:js/mutations/AddUserMutation.js
.
so what i did wrong here , i searched many sites still able to find a solution for this . can someone help/clarify me on this .