@nicolasparada/graphiql-middleware

    0.1.0 • Public • Published

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

    Install

    npm i @nicolasparada/graphiql-middleware

    DownloadsWeekly Downloads

    7

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • nicolasparada