@nicolasparada/graphql-middlewares
v0.2.0
Published
GraphQL Middlewares
Downloads
1
Maintainers
Readme
@nicolasparada/graphql-middlewares
GraphQL Middlewares
Usage
const framework = require('@nicolasparada/web-framework')
const bodyparser = require('@nicolasparada/bodyparser-middleware')
const { graphql, graphiql } = require('@nicolasparada/graphql-middlewares')
const { makeExecutableSchema } = require('graphql-tools')
const typeDefs = `
type Query {
hello: String!
}
`
const resolvers = {
Query: {
hello: () => 'Hello, world!'
}
}
const schema = makeExecutableSchema({ typeDefs, resolvers })
const app = framework()
app.post('/graphql', bodyparser.json(), graphql({ schema }))
app.get('/graphiql', graphiql({ endpointURL: '/graphql' }))
app.listen(80, '127.0.0.1', () => {
console.log('Server running at http://localhost/graphiql 🚀')
})