docs(graphql-server): update example code to Typescript and parameter name (#640)
* fix(graphql-server): update parameter name in `RootResolver` type from `ctx` to `c` * docs(graphql-server): update README to use TypeScript in example codepull/644/head
parent
e6afa4bd3d
commit
cc1e8a4911
|
@ -16,11 +16,11 @@ yarn add @hono/graphql-server
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
index.js:
|
index.ts:
|
||||||
|
|
||||||
```js
|
```ts
|
||||||
import { Hono } from 'hono'
|
import { Hono } from 'hono'
|
||||||
import { graphqlServer } from '@hono/graphql-server'
|
import { type RootResolver, graphqlServer } from '@hono/graphql-server'
|
||||||
import { buildSchema } from 'graphql'
|
import { buildSchema } from 'graphql'
|
||||||
|
|
||||||
export const app = new Hono()
|
export const app = new Hono()
|
||||||
|
@ -31,7 +31,7 @@ type Query {
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
const rootResolver = (ctx) => {
|
const rootResolver: RootResolver = (c) => {
|
||||||
return {
|
return {
|
||||||
hello: () => 'Hello Hono!',
|
hello: () => 'Hello Hono!',
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { parseBody } from './parse-body'
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export type RootResolver<E extends Env = any, P extends string = any, I extends Input = {}> = (
|
export type RootResolver<E extends Env = any, P extends string = any, I extends Input = {}> = (
|
||||||
// eslint-enable-next-line @typescript-eslint/no-explicit-any
|
// eslint-enable-next-line @typescript-eslint/no-explicit-any
|
||||||
ctx?: Context<E, P, I>
|
c?: Context<E, P, I>
|
||||||
) => Promise<unknown> | unknown
|
) => Promise<unknown> | unknown
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
|
Loading…
Reference in New Issue