fix(graphql-server): the resolver always has context as the argument (#705)
* feat(types): the resolver always has context as the argument * make it `patch` releasepull/712/head
parent
1bd5cdcd09
commit
9cac146245
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@hono/graphql-server': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Make argument (context) for the root resolver function from optional to required.
|
|
@ -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
|
||||||
c?: 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
|
||||||
|
|
|
@ -79,8 +79,8 @@ describe('GraphQL Middleware - Simple way', () => {
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
const rootResolver: RootResolver = (ctx?: Context) => {
|
const rootResolver: RootResolver = (c: Context) => {
|
||||||
const name = ctx?.get('name')
|
const name = c.get('name')
|
||||||
return {
|
return {
|
||||||
hi: `hi ${name}`,
|
hi: `hi ${name}`,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue