且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GraphQLError:必须提供查询根类型

更新时间:2023-02-14 21:10:20

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

All servers running with GraphQL must have at least one @Query() to be considered a valid GraphQL server. Without it, the apollo-server package will throw an exception and the server will fail to start. This can be as simple as

@Resolver()
export class FooResolver {

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