NestJs GraphQL playground access
I can't seem to access the GraphQL Playground using NestJS. I'm exploring the documentation and have followed this https://docs.nestjs.com/graphql/quick-start up to the Resolvers section to generate the schema.gql
, but attempting to reach localhost:3000/graphql
is not able to connect.
At first I thought my code was setup incorrectly, but I spent some time digging into Nest's examples and found that those also do not work when trying to access the /graphql
endpoint. It does work if I setup a get
endpoint to return a JSON body using the REST method.
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 {}
This is directly from the NestJS example. My understanding is that the GraphQLModule should be setting up the connection to the /graphql
endpoint. Following the docs, graphql, apollo-server-express, and graphql-tools
were all installed.
Any idea why the graphql route is not connecting?
[Edit]: Things I've tried so far:
- setting
playground: true
explicitly with GraphQLModule.forRoot - verified
NODE_ENV
is not 'production' - confirmed server works when creating resolvers using REST
- curl'd
localhost:3000/graphql
and receive a graphql validation error, so confirm that connects correctly
sometimes helmet
causes this same issue. if you have helmet loaded as a middleware, it might probably also cause this.