0.1.0 • Published 7 years ago

@nicolasparada/graphiql-middleware v0.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

@nicolasparada/graphiql-middleware npm version dependencies

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 🚀')
})