Skip to content

Instantly share code, notes, and snippets.

@chris-feist
Created March 3, 2020 20:08
Show Gist options
  • Save chris-feist/7d09304ec9631a1464cacb1bcfb107e0 to your computer and use it in GitHub Desktop.
Save chris-feist/7d09304ec9631a1464cacb1bcfb107e0 to your computer and use it in GitHub Desktop.
GraphQL Playground Handler for production GraphQL server example
import { ApolloServer } from 'apollo-server-lambda';
import lambdaPlayground from 'graphql-playground-middleware-lambda';
import schema from './schema';
const ENABLE_INTROSPECTION = process.env.STAGE !== 'prod';
const server = new ApolloServer({
schema,
playground: ENABLE_INTROSPECTION,
introspection: ENABLE_INTROSPECTION,
});
export const graphQlHandler = server.createHandler({
cors: {
origin: '*',
credentials: true,
},
});
export const playgroundHandler = lambdaPlayground({
endpoint: `/${process.env.STAGE}/graphql`,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment