honojs-middleware/packages/graphql-server
Jonathan Haines 4d67af162f
test(workspace): upgrade to vitest v3 (#1009)
* test(workspace): upgrade to vitest v3

Fixes #1007

* chore(standard-validator): add vitest type to `tsconfig.json`

* chore: update `yarn.lock`

* chore(zod-openapi): bump `typescript`

* chore(typia-validator): make it ESM

* ci(bun-transpiler): fix Bun to v1.1.32

---------

Co-authored-by: Yusuke Wada <yusuke@kamawada.com>
2025-03-12 12:52:15 +09:00
..
bun_test chore: add lint rule and format (#367) 2024-01-29 22:53:43 +09:00
src chore: Migrate workspaces that use `jest` to `vitest` (#998) 2025-03-04 22:00:28 +09:00
CHANGELOG.md Version Packages (#712) 2024-08-25 11:33:27 +09:00
README.md feat(graphql-server): add GraphiQL support (#670) 2024-07-29 21:44:54 +09:00
package.json test(workspace): upgrade to vitest v3 (#1009) 2025-03-12 12:52:15 +09:00
tsconfig.json chore: Migrate workspaces that use `jest` to `vitest` (#998) 2025-03-04 22:00:28 +09:00
vitest.config.ts test(workspace): upgrade to vitest v3 (#1009) 2025-03-12 12:52:15 +09:00

README.md

GraphQL Server Middleware

Requirements

This middleware depends on GraphQL.js.

npm i @hono/graphql-server

or

yarn add @hono/graphql-server

Usage

index.ts:

import { Hono } from 'hono'
import { type RootResolver, graphqlServer } from '@hono/graphql-server'
import { buildSchema } from 'graphql'

export const app = new Hono()

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

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

app.use(
  '/graphql',
  graphqlServer({
    schema,
    rootResolver,
    graphiql: true, // if `true`, presents GraphiQL when the GraphQL endpoint is loaded in a browser.
  })
)

app.fire()

Author

Minghe Huang h.minghe@gmail.com