Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #5025: Add env. vars. for graphql playground and introspection #5055

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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