Skip to content

Instantly share code, notes, and snippets.

@cop1fab
Created January 28, 2020 10:34
Show Gist options
  • Save cop1fab/b4683b9c31940e411ddfa3e0cca58505 to your computer and use it in GitHub Desktop.
Save cop1fab/b4683b9c31940e411ddfa3e0cca58505 to your computer and use it in GitHub Desktop.
GraphQL | Express
const express = require('express');
const express_graphql = require('express-graphql');
const { buildSchema } = require('graphql');
const schema = buildSchema(`
type Query{
message: String
}
`);
// RESOLVERS
const root = {
message: () => 'Hello world'
}
const app = express();
app.use('/graphql', express_graphql({
schema: schema,
rootValue: root,
graphiql: true
}));
const port = process.env.PORT || 7000;
app.listen(port, () => console.log(`App started and successfully & is listening to port ${port}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment