I would like to have an endpoint "forgotPassword" where an input is email, and there is no output (the result of the action is an email sent to the user). This looks like a mutation, rather than a query. I'm using graphqli on the front, and graphql-relay with node, express on the backend. I have this so far:
import {
fromGlobalId,
connectionDefinitions,
forwardConnectionArgs,
connectionFromArraySlice,
cursorToOffset,
mutationWithClientMutationId,
graphql,
} from 'graphql-relay'
import { GraphQLObjectType,
GraphQLInputObjectType,
GraphQLString, GraphQLNonNull, GraphQLID, GraphQLInt, GraphQLBoolean, } from 'graphql'
const forgotPassword = mutationWithClientMutationId({
name: 'forgotPassword',
inputFields: {
email: { type: GraphQLString },
},
outputFields: {
email: { type: GraphQLString },
},
mutateAndGetPayload: (arg1, arg2) => {
console.log('+++ forgotPassword mutate and get payload:', arg1, arg2)
return "status: ok"
}
})
What am I doing wrong, how do I fix this error? Also, what should I use to define a mutation, is it "mutationWithClientMutationId" or another method is preferable?
How can I make is so that there isn't a return value? (I'm currently returning the email)
My guess is that the argument email: $email
should be wrapped in an input object like this:
input: {
email: $email
}
I personally don't use relay's mutation helper function.