0
0
mirror of https://github.com/honojs/hono.git synced 2024-12-01 11:51:01 +01:00
hono/deno_dist/middleware/graphql-server
2022-07-02 22:31:10 +09:00
..
index.ts feat: support Deno! (#336) 2022-07-02 15:09:45 +09:00
parse-body.ts feat: support Deno! (#336) 2022-07-02 15:09:45 +09:00
README.md feat: support Deno! (#336) 2022-07-02 15:09:45 +09:00

GraphQL Server Middleware

Requirements

This middleware depends on GraphQL.js.

npm i graphql

or

yarn add graphql

Usage

index.js:

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

export const app = new Hono()

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

const rootValue = {
  hello: () => 'Hello Hono!',
}

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

app.fire()