* docs(contributing): add section on testing Fixes #994 * test(clerk-auth): replace jest with vitest * test(graphql-server): replace jest with vitest * test(medley-router): replace jest with vitest * test(oauth-providers): replace jest with vitest * test(oidc-auth): replace jest with vitest * test(sentry): replace jest with vitest * test(trpc-server): replace jest with vitest * test(typebox-validator): replace jest with vitest * test(typia-validator): replace jest with vitest * test(valibot-validator): replace jest with vitest * chore: cleanup remaining references to jest * chore: fix lint errors * test(typia-validator): fix exclude directory * test(oauth-providers): use vitest environment miniflare * chore: update `yarn.lock` * chore(zod-openapi): pin zod-validator to 0.4.2 * test(graphql-server): remove console filtering --------- Co-authored-by: Yusuke Wada <yusuke@kamawada.com> |
||
---|---|---|
.. | ||
bun_test | ||
src | ||
CHANGELOG.md | ||
README.md | ||
package.json | ||
tsconfig.json | ||
vitest.config.ts |
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