Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Pattern matching all endpoints with graphql or graphiql with 1 or more leading underscores
*/
const graphqlEndpoint = `/_+graphi?ql`
if (process.env.GATSBY_GRAPHQL_IDE === `playground`) {
app.get(
graphqlEndpoint,
graphqlPlayground({
endpoint: `/___graphql`,
}),
() => {}
)
} else {
graphiqlExplorer(app, {
graphqlEndpoint,
})
}
app.use(
graphqlEndpoint,
graphqlHTTP(() => {
const { schema, schemaCustomization } = store.getState()
return {
schema,
graphiql: false,
context: withResolverContext({
schema,
schemaComposer: schemaCustomization.composer,
context: {},