gpt4 book ai didi

postgresql - GraphQLError : Query root type must be provided

转载 作者:行者123 更新时间:2023-12-04 11:04:51 37 4
gpt4 key购买 nike

我的后端 API 使用 NestJS、TypeORM 和 GraphQL。我收到以下错误:

GraphQLError [Object]: Query root type must be provided.
at SchemaValidationContext.reportError (/home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/graphql/type/validate.js:88:19)
at validateRootTypes (/home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/graphql/type/validate.js:107:13)
at validateSchema (/home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/graphql/type/validate.js:52:3)
at graphqlImpl (/home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/graphql/graphql.js:79:62)
at /home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/graphql/graphql.js:28:59
at new Promise (<anonymous>)
at Object.graphql (/home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/graphql/graphql.js:26:10)
at GraphQLSchemaFactory.<anonymous> (/home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/@nestjs/graphql/dist/schema-builder/graphql-schema.factory.js:49:52)
at Generator.next (<anonymous>)
at /home/wise-introvert/Container/Projects/the-notebook/app/server/node_modules/tslib/tslib.js:114:75
这是我的文件结构和代码的样子:
enter image description here
有人可以帮帮我吗。我的仓库: https://github.com/wise-introvert/nestjs-graphql-api.git

最佳答案

所有运行 GraphQL 的服务器必须至少有一个 @Query()被视为有效的 GraphQL 服务器。没有它,apollo-server 包将抛出异常,服务器将无法启动。这可以很简单

@Resolver()
export class FooResolver {

@Query(() => String)
sayHello(): string {
return 'Hello World!';
}
}

关于postgresql - GraphQLError : Query root type must be provided,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64105940/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com