Skip to content

Instantly share code, notes, and snippets.

@stubailo
Last active March 12, 2018 15:13
Show Gist options
  • Save stubailo/6195d39b3f10500326d62aa1bc2aab0b to your computer and use it in GitHub Desktop.
Save stubailo/6195d39b3f10500326d62aa1bc2aab0b to your computer and use it in GitHub Desktop.
Engine setup with Apollo Server
// Install and import the apollo-engine package
const { ApolloEngine } = require('apollo-engine');
const { graphqlExpress } = require('apollo-server-express');
const app = express();
// Enable tracing and cacheControl in Apollo Server
app.use('/graphql', graphqlExpress({
tracing: true,
cacheControl: true,
schema: schema,
// ... other options
});
// Initialize Engine with an API key
const engine = new ApolloEngine({ apiKey: 'API_KEY' });
// Replace app.listen() with engine.listen()
engine.listen({
port: 3000,
expressApp: app,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment