[英]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.