小编cli*_*qer的帖子

GraphQL 突变和查询:无法读取未定义的属性

我正在按照教程进行操作,并使用express-graphql. 我有一个突变来创建一个Friend对象和一个查询来返回相同的对象。自动完成和模式检测在 localhost:8080/graphql 上运行的 GraphiQL 上运行良好。我尝试在 SO 上搜索类似的错误,但这些错误要么有复杂的示例,要么正在使用 Apollo。

这是我尝试执行的 GraphQL 突变:

mutation {
  createFriend(input: {
    firstName:"FName1",
    lastName:"LName1",
    email:"test@test.com"
  }) {
    id
  }
}
Run Code Online (Sandbox Code Playgroud)

和我看到的错误(仅显示错误的相关部分):

{
  "errors": [
    {
      "message": "Cannot read property 'input' of undefined",
// Erased irrelevant portion of error
}
Run Code Online (Sandbox Code Playgroud)

这是我的 schema.js 文件,它导入resolversresolvers.js使用makeExecutableSchema

import { resolvers } from './resolvers';
import { makeExecutableSchema } from '@graphql-tools/schema';

const typeDefs = `
    type Friend {
        id: ID
        firstName: String
        lastName: …
Run Code Online (Sandbox Code Playgroud)

reactjs graphql express-graphql

2
推荐指数
1
解决办法
3135
查看次数

标签 统计

express-graphql ×1

graphql ×1

reactjs ×1