Created
March 3, 2020 20:08
-
-
Save chris-feist/7d09304ec9631a1464cacb1bcfb107e0 to your computer and use it in GitHub Desktop.
GraphQL Playground Handler for production GraphQL server example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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