Skip to content

Instantly share code, notes, and snippets.

@command-tab
Created August 4, 2018 04:04
Show Gist options
  • Save command-tab/b782b9a3064fafb22eda43b1410e8e98 to your computer and use it in GitHub Desktop.
Save command-tab/b782b9a3064fafb22eda43b1410e8e98 to your computer and use it in GitHub Desktop.
Customizing Apollo Server 2.0 GraphQL Playground path
const express = require('express');
const { ApolloServer, gql } = require('apollo-server-express');
const { typeDefs, resolvers } = require('./schema');
// https://www.apollographql.com/docs/apollo-server/features/graphql-playground.html#Enabling-GraphQL-Playground-in-production
const server = new ApolloServer({
typeDefs,
resolvers,
introspection: true,
playground: {
settings: {
'editor.theme': 'light'
}
}
});
// Additional middleware can be mounted at this point to run before Apollo
const app = express();
server.applyMiddleware({ app, path: '/somepath' });
// Start the server
const port = 8080;
app.listen({ port }, () => {
console.log(`Liftoff of Apollo Server at http://localhost:${port}${server.graphqlPath}`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment