Skip to content

Commit

Permalink
Refactor #5025: Add env. vars. for graphql playground and introspection
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Lehnen <[email protected]>
  • Loading branch information
lehnenb committed Mar 19, 2019
1 parent 1d83bc1 commit 5ae0a09
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ REACTION_USER_NAME=admin
REACTION_USER=Admin
ROOT_URL=http://localhost:3000
IDENTITY_PROVIDER_MODE=all
GRAPHQL_INTROSPECTION_ENABLED=true
GRAPHQL_PLAYGROUND_ENABLED=true
9 changes: 8 additions & 1 deletion imports/node-app/core/createApolloServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import cors from "cors";
import express from "express";
import { makeExecutableSchema, mergeSchemas } from "apollo-server";
import { ApolloServer } from "apollo-server-express";
import envalid, { bool } from "envalid";
import buildContext from "./util/buildContext";
import getErrorFormatter from "./util/getErrorFormatter";
import tokenMiddleware from "./util/tokenMiddleware";
Expand Down Expand Up @@ -31,6 +32,10 @@ export default function createApolloServer(options = {}) {
const schemas = options.schemas || [];
const schemasToMerge = schemas.filter((td) => typeof td !== "string");
const typeDefs = schemas.filter((td) => typeof td === "string");
const env = envalid.cleanEnv(process.env, {
GRAPHQL_INTROSPECTION_ENABLED: bool({ default: false }),
GRAPHQL_PLAYGROUND_ENABLED: bool({ default: false })
});

// Create a custom Express server so that we can add our own middleware and HTTP routes
const app = express();
Expand Down Expand Up @@ -59,7 +64,9 @@ export default function createApolloServer(options = {}) {
schema,
subscriptions: {
path
}
},
instrospection: env.GRAPHQL_INSTROSPECTION_ENABLED,
playground: env.GRAPHQL_PLAYGROUND_ENABLED
});

// GraphQL endpoint, enhanced with JSON body parser
Expand Down

0 comments on commit 5ae0a09

Please sign in to comment.