Created
July 7, 2017 15:24
-
-
Save a7v8x/a4372c4f1065b6f9210096644ff91f19 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
import express from 'express'; | |
import graphqlHTTP from 'express-graphql'; | |
import schema from './graphql/schema'; | |
const app = express(); | |
const dev = process.env.NODE_ENV === 'development'; | |
app.use('/graphql', graphqlHTTP({ | |
schema, | |
graphiql: dev, | |
})); | |
app.use('/', (req, res) => { | |
res.json('Go to /graphql to test your queries and mutations :)'); | |
}); | |
const server = app.listen(3000, () => { | |
const { port } = server.address(); | |
console.info(`\n\nExpress listen at http://localhost:${port} \n`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment