honojs-middleware/packages/graphql-server
Antony David f7a950a649
chore(eslint-config): use modern plugins alternatives (#724)
* chore(eslint-config): use modern plugins alternatives

* chore: migrate missing ones

* chore: migrate eslint plugin comments

* fix(eslint): update configuration

* chore: bump eslint dev deps

* chore: add changeset
2024-09-08 08:38:30 +09:00
..
bun_test chore: add lint rule and format (#367) 2024-01-29 22:53:43 +09:00
src fix(graphql-server): the resolver always has context as the argument (#705) 2024-08-25 11:29:19 +09:00
test fix(graphql-server): the resolver always has context as the argument (#705) 2024-08-25 11:29:19 +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
jest.config.js chore(graphql-server): setup 2023-02-04 11:53:27 +09:00
package.json chore(eslint-config): use modern plugins alternatives (#724) 2024-09-08 08:38:30 +09:00
tsconfig.json chore(graphql-server): setup 2023-02-04 11:53:27 +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