"Unknown argument \"email\" 在类型为 \"Mutation\" 的字段 \"forgotPassword\" 上。"

"Unknown argument \"email\" on field \"forgotPassword\" of type \"Mutation\"."

我想要一个端点 "forgotPassword",其中输入是电子邮件,没有输出(操作的结果是发送给用户的电子邮件)。这看起来像一个突变,而不是一个查询。我在前端使用 graphqli,在后端使用 graphql-relay with node, express。到目前为止我有这个:

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" 还是其他方法更可取?

我怎样才能使 is 不存在 return 值? (我目前正在 return 发送电子邮件)

我的猜测是参数 email: $email 应该像这样包装在输入对象中:

input: {
  email: $email
}

我个人不使用relay的mutation helper函数