Created
January 4, 2018 12:10
-
-
Save jbaxleyiii/cc167197eac843e20f738a152792907f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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