[英]“Unknown argument \”email\“ on field \”forgotPassword\“ of type \”Mutation\“.”
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). 我希望有一个端点“ forgotPassword”,其中输入是电子邮件,没有输出(操作的结果是发送给用户的电子邮件)。 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.
我在前端使用graphqli,在后端使用带有节点的graphql-relay。 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?
另外,我应该使用什么来定义一个突变,是“ mutationWithClientMutationId”还是其他方法更可取?
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: 我的猜测是,参数
email: $email
应该包装在这样的输入对象中:
input: {
email: $email
}
I personally don't use relay's mutation helper function. 我个人不使用中继的突变帮助功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.