Created
January 28, 2020 10:34
-
-
Save cop1fab/b4683b9c31940e411ddfa3e0cca58505 to your computer and use it in GitHub Desktop.
GraphQL | Express
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 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