Elb*_*Bae 7 node.js graphql nestjs
我似乎无法使用 NestJS 访问 GraphQL Playground。我正在探索文档并按照此https://docs.nestjs.com/graphql/quick-start一直到解析器部分来生成schema.gql,但尝试访问localhost:3000/graphql无法连接。
起初我以为我的代码设置不正确,但我花了一些时间深入研究 Nest 的示例,发现这些示例在尝试访问端点时也不起作用/graphql。get如果我设置一个端点以使用 REST 方法返回 JSON 正文,它确实有效。
import { Module } from '@nestjs/common';
import { GraphQLModule } from '@nestjs/graphql';
import { RecipesModule } from './recipes/recipes.module';
@Module({
imports: [
RecipesModule,
GraphQLModule.forRoot({
installSubscriptionHandlers: true,
autoSchemaFile: 'schema.gql',
}),
],
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)
这直接来自 NestJS 示例。我的理解是 GraphQLModule 应该设置与/graphql端点的连接。按照文档,graphql, apollo-server-express, and graphql-tools全部安装完毕。
知道为什么 graphql 路由没有连接吗?
[编辑]:到目前为止我尝试过的事情:
playground: true使用 GraphQLModule.forRoot 显式设置NODE_ENV不是“生产”localhost:3000/graphql并收到 graphql 验证错误,因此请确认连接正确Elb*_*Bae -1
似乎是在 Windows 10 上运行 WSL2 的问题。github 上的这个线程对这个问题有一些深入的了解。
禁用快速启动以允许访问本地主机。
https://github.com/microsoft/WSL/issues/5298