简体   繁体   English

类型为“ Mutation \\”的字段“ forgotPassword \\”上的“未知参数\\” email \\”。”

[英]“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"
  }
})

And then I get: 然后我得到: 在此处输入图片说明

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.

相关问题 在Relay中创建嵌套变异会抛出未知字段 - Creating nested mutation in Relay throws unknown field 如何修复 Vuex 中未知突变类型的错误? - How to fix the error of unknown mutation type in Vuex? Graphql 字段上的未知参数 - Graphql Unknown argument on field 注册模块中的vuex未知突变类型 - vuex unknown mutation type in registered module 无法在类型 \\&quot;Mutation\\&quot; 上查询字段 \\&quot;addWorkout\\&quot; - Cannot query field \"addWorkout\" on type \"Mutation\ 我正在切换侧边栏的“未知突变类型:mobilenav/showmobilenav” - I am getting `unknown mutation type: mobilenav/showmobilenav` toggling a sidebar 为什么我的 Vuex 模块不工作? [vuex] 未知突变类型:moduleName/mutation - Why isnt my Vuex modules working? [vuex] unknown mutation type: moduleName/mutation 收到错误:类型为“查询” [GraphQL,Relay,React]的字段“用户”上的未知参数“ id” - Getting error : Unknown argument “id” on field “user” of type “Query” [GraphQL, Relay, React] <Mutation /> refetchQueries“未知指令“ _”。” - <Mutation /> refetchQueries “Unknown directive ”_“.” Nuxt,将Vuex存储拆分为单独的文件会产生错误:未知突变类型:登录 - Nuxt, splitting up Vuex store into separate files gives error: unknown mutation type: login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM