Created
August 4, 2018 04:04
-
-
Save command-tab/b782b9a3064fafb22eda43b1410e8e98 to your computer and use it in GitHub Desktop.
Customizing Apollo Server 2.0 GraphQL Playground path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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