@hono/graphql-server
TypeScript icon, indicating that this package has built-in type declarations

0.5.1 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i @hono/graphql-server

Weekly Downloads

5,798

Version

0.5.1

License

MIT

Unpacked Size

13.9 kB

Total Files

6

Last publish

Collaborators

  • yusukebe