简体   繁体   English

graphql-compose:TypeError:无法读取未定义的属性“ getTypeName”

[英]graphql-compose: TypeError: Cannot read property 'getTypeName' of undefined

I am trying out graphql-compose library and following their Getting started Github page , I build a very simple example. 我正在尝试graphql-compose库,并按照他们的Github入门页面进行构建,这是一个非常简单的示例。

Here is my code: 这是我的代码:

    import { schemaComposer } from "graphql-compose";

    export const UserTC = schemaComposer.createObjectTC({
      name: "UserTC",
      fields: {
        name: "String",
        surname: "String"
      }
    });

    UserTC.addResolver({
      kind: "query",
      name: "userFind",
      resolve: async () => {
       return []; // empty array
      }
    });

    schemaComposer.Query.addFields({
      userFind: UserTC.getResolver("userFind")
    });

    export const schema = schemaComposer.buildSchema()

I am getting the below error when I pass the returned schema object into 将返回的架构对象传递到时出现以下错误
my Apollo server: 我的Apollo服务器:

TypeError: Cannot read property 'getTypeName' of undefined

The error stack point to the last line of my code. 错误堆栈指向我的代码的最后一行。 I cannot figure out what I am doing wrong. 我无法弄清楚我在做什么错。

Thanks for your help. 谢谢你的帮助。

I can possible not see what error I am doind 我看不到我是什么错误

add "type" to resolver: 向解析器添加“类型”:

UserTC.addResolver({
  kind: "query",
  name: "userFind",
  type: UserTC,
  resolve: async () => {
   return []; // empty array
  }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GraphQL:TypeError:无法读取未定义的属性 - GraphQL: TypeError: Cannot read property of undefined 类型错误:无法读取未定义的 Graphql、Nodejs 的属性“forEach” - TypeError: Cannot read property 'forEach' of undefined Graphql, Nodejs Nativewscript-vue graphql:TypeError:无法读取未定义的属性“地图” - Nativewscript-vue graphql: TypeError: Cannot read property 'map' of undefined Auth0 和 Graphql 出错 - TypeError:无法读取未定义的属性“publicKey” - Error with Auth0 and Graphql - TypeError: Cannot read property 'publicKey' of undefined 未处理的拒绝(TypeError):无法读取未定义的属性“refetch” - GraphQL - Unhandled Rejection (TypeError): Cannot read property 'refetch' of undefined - GraphQL TypeError:无法读取未定义的属性“匹配”(反应和 graphql) - TypeError: Cannot read property 'match' of undefined ( react and graphql ) “TypeError:无法使用 graphql 和 mongodb 读取未定义的属性‘原型’”nestjs - "TypeError: Cannot read property 'prototype' of undefined" nestjs with graphql and mongodb Graphql,React - TypeError:无法读取未定义的属性“地图” - Graphql, React - TypeError: Cannot read property 'map' of undefined 未捕获的TypeError:无法使用Gatsby和graphQl读取未定义的属性“数据” - Uncaught TypeError: Cannot read property 'data' of undefined with Gatsby and graphQl Apollo GraphQL - 类型错误:无法读取未定义的属性“findOrCreateUser” - Apollo GraphQL - TypeError: Cannot read property 'findOrCreateUser' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM