我使用 NestJS、TypeORM 和 GraphQL 作为我的后端 API。我收到以下错误:
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
This is what my file structure and code looks like:
有人可以帮帮我吗。我的仓库:https://github.com/wise-introvert/nestjs-graphql-api.git 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!';
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)