调用 GraphQL 突变 GRAPHQL_VALIDATION_FAILED

Call GrapQL mutation GRAPHQL_VALIDATION_FAILED

我有这个架构:

type Mutation {
  createUser(data: UserProps!): User!
}

input UserProps {
  name: String!
  email: String!
  password: String!
  image: String!
}

我想调用突变

mutation {
  createUser(name: "Rodrigo", email: "email@example.com", password: "foobar", image: "https://...") {
    name,
    password
  }
}

但是我得到了错误:

{ "error": { "errors": [ { "message": "Unknown argument "name" on field "Mutation.createUser".", "extensions": { "code": "GRAPHQL_VALIDATION_FAILED", "exception": { "stacktrace": [ "GraphQLError: Unknown argument "name" on field "Mutation.createUser".", " at Object.Argument (/app/node_modules/graphql/validation/rules/KnownArgumentNamesRule.js:46:29)", " at Object.enter (/app/node_modules/graphql/language/visitor.js:323:29)", " at Object.enter (/app/node_modules/graphql/utilities/TypeInfo.js:370:25)", " at visit (/app/node_modules/graphql/language/visitor.js:243:26)", " at validate (/app/node_modules/graphql/validation/validate.js:69:24)", " at validate (/app/node_modules/apollo-server-core/dist/requestPipeline.js:186:39)", " at processGraphQLRequest (/app/node_modules/apollo-server-core/dist/requestPipeline.js:98:34)", " at processTicksAndRejections (internal/process/task_queues.js:95:5)", " at async processHTTPRequest (/app/node_modules/apollo-server-core/dist/runHttpQuery.js:187:30)" ] } } }, { "message": "Unknown argument "email" on field "Mutation.createUser".", "extensions": { "code": "GRAPHQL_VALIDATION_FAILED", "exception": { "stacktrace": [ "GraphQLError: Unknown argument "email" on field "Mutation.createUser".", " at Object.Argument (/app/node_modules/graphql/validation/rules/KnownArgumentNamesRule.js:46:29)", " at Object.enter (/app/node_modules/graphql/language/visitor.js:323:29)", " at Object.enter (/app/node_modules/graphql/utilities/TypeInfo.js:370:25)", " at visit (/app/node_modules/graphql/language/visitor.js:243:26)", " at validate (/app/node_modules/graphql/validation/validate.js:69:24)", " at validate (/app/node_modules/apollo-server-core/dist/requestPipeline.js:186:39)", " at processGraphQLRequest (/app/node_modules/apollo-server-core/dist/requestPipeline.js:98:34)", " at processTicksAndRejections (internal/process/task_queues.js:95:5)", " at async processHTTPRequest (/app/node_modules/apollo-server-core/dist/runHttpQuery.js:187:30)" ] } } },

可以是什么?

解决方法:

mutation {
  createUser(data: {name: "Rodrigo", email: "email@example.com", password: "foobar", image: "https://..."}) {
    name,
    password
  }
}