Skip to content

Instantly share code, notes, and snippets.

@drFabio
Created October 19, 2016 14:12
Show Gist options
  • Save drFabio/9fe2d882fd755019cbf6885d4843a8fe to your computer and use it in GitHub Desktop.
Save drFabio/9fe2d882fd755019cbf6885d4843a8fe to your computer and use it in GitHub Desktop.
const { apolloExpress, graphiqlExpress } = require('apollo-server');
const { makeExecutableSchema } = require('graphql-tools')
const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser')
//Your schema declaration herte
const typeDefs = require('./schema')
const schemaOptions = {
typeDefs,
resolvers,
// allowUndefinedInResolve:true,
// resolverValidationOptions: {
// requireResolversForNonScalar: false
// }
}
const schema = makeExecutableSchema(schemaOptions)
app.use(cors())
app.use('/graphql',
bodyParser.json(),
apolloExpress({
schema
})
)
app.use('/graphiql', graphiqlExpress({
endpointURL: '/graphql',
}));
app.listen(process.env.PORT || 4000, "0.0.0.0", () => console.log(`Now browse to localhost:${process.env.PORT || 4000}/graphiql for UI or localhost:${process.env.PORT || 4000}/graphql for API`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment