I am having trouble returning data from a mutation using React.js, Node.js, and GraphQL. I am returning the data from a Node.js API:
return resolve({
id: null,
authToken: null,
res: "The credentials you provided are incorrect."
})
That data is returned in a mutation:
const ResponseType = new GraphQLObjectType({
name: 'Response',
fields: () => ({
id: { type: GraphQLID },
authToken: { type: GraphQLString },
response: { type: GraphQLString }
})
})
const Mutation = new GraphQLObjectType({
name: 'Mutation',
fields: {
signIn: {
type: ResponseType,
args: {
credential: { type: new GraphQLNonNull(GraphQLString) },
password: { type: new GraphQLNonNull(GraphQLString) }
},
async resolve(parent, args) {
var response = await accounts.signIn(args.credential, args.password);
console.log(response);
return response;
}
}
}
})
It prints the following using console.log():
{
id: null,
authToken: null,
response: 'The credentials you provided are incorrect.'
}
And returns this in GraphiQL:
But in my react app, with the below code, I get this data:
const [ signIn, { data, loading, error }] = useMutation(SIGN_IN);
if (data != undefined) {
console.log(data);
}
return (
<form className="form flex col" id="sign-in" onSubmit={(e) => {
e.preventDefault();
signIn({
variables: {
credential: credential,
password: password
}
})
}}>
</form>
)
{signIn: {id: null, authToken: null, __typename: "Response"}}
The problem is in my React app, response is nowhere to be found despite printing in my API and being returned in my GraphiQL query. Any help would be greatly appreciated. Thank you.

I needed to include
responsein mygqlquery.