Monday, July 12, 2021

how to disable graphql in Apollo Server?

 It is very convenient to have graphql playground enable on the Apollo Server during the development.

However there will be a security issue if we have this feature enable on the production server. we must 

turn off this feature in the production environment.  we can easily turn on/off this feature on the Apollo

Server configuration setup. I create a environment variable to control this feature.

const apolloServer = new ApolloServer({
        schema: await buildSchema({
          resolvers: [UserResolvers]
        }),
        context: ({ reqres }) => ({ reqres }),
        introspection: process.env.DEV_ENV==="development",
        playground: process.env.DEV_ENV==="development",});

No comments:

Post a Comment