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` release
pull/712/head
Minghe 2024-08-25 04:29:19 +02:00 committed by GitHub
parent 1bd5cdcd09
commit 9cac146245
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/graphql-server': patch
---
Make argument (context) for the root resolver function from optional to required.

View File

@ -23,7 +23,7 @@ import { parseBody } from './parse-body'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type RootResolver<E extends Env = any, P extends string = any, I extends Input = {}> = (
// eslint-enable-next-line @typescript-eslint/no-explicit-any
c?: Context<E, P, I>
c: Context<E, P, I>
) => Promise<unknown> | unknown
// eslint-disable-next-line @typescript-eslint/no-explicit-any

View File

@ -79,8 +79,8 @@ describe('GraphQL Middleware - Simple way', () => {
}
`)
const rootResolver: RootResolver = (ctx?: Context) => {
const name = ctx?.get('name')
const rootResolver: RootResolver = (c: Context) => {
const name = c.get('name')
return {
hi: `hi ${name}`,
}