/graphql-server

[moved]

Primary LanguageTypeScript

GraphQL Server Middleware

Requirements

This middleware depends on GraphQL.js.

npm i @honojs/graphql-server

or

yarn add @honojs/graphql-server

Usage

index.js:

import { Hono } from 'hono'
import { graphqlServer } from '@honojs/graphql-server'
import { buildSchema } from 'graphql'

export const app = new Hono()

const schema = buildSchema(`
type Query {
  hello: String
}
`)

const rootResolver = (ctx) => {
  return {
    hello: () => 'Hello Hono!',
  }
}

app.use(
  '/graphql',
  graphqlServer({
    schema,
    rootResolver,
  })
)

app.fire()