diff --git a/Dockerfile b/Dockerfile index bf8a1e9d..41850efe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,3 +29,4 @@ COPY --from=builder /srv/www/build ./build COPY src/jade ./build/jade COPY src/util/protobuf ./build/util/protobuf COPY package.json package-lock.json ecosystem.config.js ./ +COPY static ./static diff --git a/src/index.js b/src/index.js index ecc5d54f..42a71d73 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,7 @@ import pug from 'pug'; import { printSchema } from 'graphql/utilities'; import { ApolloServer } from 'apollo-server-koa'; import koaStatic from 'koa-static'; +import koaSend from 'koa-send'; import koaBody from 'koa-bodyparser'; import session from 'koa-session2'; import passport from 'koa-passport'; @@ -75,6 +76,10 @@ router.post('/logout', checkHeaders(), (ctx) => { router.options('/graphql', checkHeaders()); router.post('/graphql', checkHeaders()); +router.get('/graphql', (ctx) => { + return koaSend(ctx, '/static/graphiql.html'); +}); + const schemaStr = printSchema(schema); const indexFn = pug.compileFile(path.join(__dirname, 'jade/index.jade')); router.get('/', (ctx) => { @@ -100,7 +105,7 @@ const LOGGER_HEADER_KEY_REGEX = /ip|forwarded|address/i; export const apolloServer = new ApolloServer({ schema, introspection: true, // Allow introspection in production as well - playground: true, + playground: false, context: async ({ ctx }) => { const { appId, diff --git a/static/graphiql.html b/static/graphiql.html new file mode 100644 index 00000000..a72b114e --- /dev/null +++ b/static/graphiql.html @@ -0,0 +1,68 @@ + + + + + + GraphiQL + + + + + + + + + + + + + + +
Loading...
+ + + + \ No newline at end of file