Created
October 19, 2016 14:12
-
-
Save drFabio/9fe2d882fd755019cbf6885d4843a8fe to your computer and use it in GitHub Desktop.
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 { 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