@nicolasparada/graphql-middlewares

0.2.0 • Public • Published

@nicolasparada/graphql-middlewares npm version dependencies

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

Package Sidebar

Install

npm i @nicolasparada/graphql-middlewares

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • nicolasparada