Nectar of the Programming Masses

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

    Install

    npm i @nicolasparada/graphql-middlewares

    DownloadsWeekly Downloads

    3

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • nicolasparada