Skip to content

Instantly share code, notes, and snippets.

@a7v8x
Created July 7, 2017 15:24
Show Gist options
  • Save a7v8x/a4372c4f1065b6f9210096644ff91f19 to your computer and use it in GitHub Desktop.
Save a7v8x/a4372c4f1065b6f9210096644ff91f19 to your computer and use it in GitHub Desktop.
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