@nicolasparada/graphiql-middleware
v0.1.0
Published
GraphiQL Middleware
Downloads
1
Readme
@nicolasparada/graphiql-middleware
GraphiQL Middleware.
Usage
const framework = require('@nicolasparada/web-framework')
const json = require('@nicolasparada/bodyparser-middleware/json')
const graphql = require('@nicolasparada/graphql-middleware')
const graphiql = require('@nicolasparada/graphiql-middleware')
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', json(), graphql({ schema }))
app.get('/graphiql', graphiql({ endpointURL: '/graphql' }))
app.listen(80, '127.0.0.1', () => {
console.log('Server running at http://localhost/graphiql 🚀')
})