Skip to content

Instantly share code, notes, and snippets.

@jbaxleyiii
Created January 4, 2018 12:10
Show Gist options
  • Select an option

  • Save jbaxleyiii/cc167197eac843e20f738a152792907f to your computer and use it in GitHub Desktop.

Select an option

Save jbaxleyiii/cc167197eac843e20f738a152792907f to your computer and use it in GitHub Desktop.
const express = require("express");
const bodyParser = require("body-parser");
const { graphqlExpress, graphiqlExpress } = require("apollo-server-express");
// import schema from generated bucklescript files
const { schema } = require("./src/Schema.bs.js");
// Initialize the app
const app = express();
const { PORT = 3000 } = process.env;
const endpointURL = `/`;
// The GraphQL endpoint
app.post(endpointURL, bodyParser.json(), graphqlExpress({ schema }));
// GraphiQL, a visual editor for queries
app.get(endpointURL, graphiqlExpress({ endpointURL }));
// Start the server
app.listen(PORT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment