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 c0e1968
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
GRAPHQL_INTROSPECTION_ENABLED=true
GRAPHQL_PLAYGROUND_ENABLED=true
HYDRA_ADMIN_URL=http://hydra:4445
HYDRA_OAUTH2_INTROSPECT_URL=http://hydra:4445/oauth2/introspect
HYDRA_TOKEN_URL=http://hydra:4444/oauth2/token
Expand Down
7 changes: 7 additions & 0 deletions imports/node-app/core/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import envalid, { bool } from "envalid";

export default envalid.cleanEnv(process.env, {
GRAPHQL_INTROSPECTION_ENABLED: bool({ default: false }),
GRAPHQL_PLAYGROUND_ENABLED: bool({ default: false })
});

5 changes: 4 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 config from "./config";
import buildContext from "./util/buildContext";
import getErrorFormatter from "./util/getErrorFormatter";
import tokenMiddleware from "./util/tokenMiddleware";
Expand Down Expand Up @@ -59,7 +60,9 @@ export default function createApolloServer(options = {}) {
schema,
subscriptions: {
path
}
},
introspection: config.GRAPHQL_INTROSPECTION_ENABLED,
playground: config.GRAPHQL_PLAYGROUND_ENABLED
});

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

0 comments on commit c0e1968

Please sign in to comment.