Skip to content

Instantly share code, notes, and snippets.

@suciuvlad
Last active July 15, 2018 16:38
Show Gist options
  • Save suciuvlad/3a7337162eac7a7f1fc3f22acf94b97d to your computer and use it in GitHub Desktop.
Save suciuvlad/3a7337162eac7a7f1fc3f22acf94b97d to your computer and use it in GitHub Desktop.
Main Service with Apollo Engine
import { ApolloEngine } from 'apollo-engine';
const app = express();
app.use(
'/graphql',
bodyParser.json(),
graphqlExpress(async (req, res) => {
...
const schema; // created previously
return {
schema: schema,
graphiql: true,
tracing: true,
cacheControl: {
defaultMaxAge: 3500
},
context: { req, res }
};
})
);
app.use('/graphiql', graphiqlExpress({ endpointURL: '/graphql' }));
const engine = new ApolloEngine({
apiKey: 'service:microservices-example:-kee_qJAX8UKDLPjI7JVjw'
});
engine.listen({
port: 4000,
expressApp: app
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment