我想要一个端点“forgotPassword”,其中输入是电子邮件,没有输出(操作的结果是发送给用户的电子邮件)。这看起来像一个突变,而不是一个查询。我在前端使用graphqli,在后端使用带有节点的graphql-relay,表示。到目前为止我有这个:
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"
}
})
我在做什么错,我该如何解决这个错误?另外,我应该用什么来定义突变,是“mutationWithClientMutationId”还是其他方法更可取?
我怎样才能做到没有返回值?(我目前正在退回电子邮件)