interface AnySubscriptionResolver

The entry type for a SUBSCRIPTION resolver stored in a TypeResolverMap.

The bivariant counterpart of AnyFieldResolver, for the same reason and by the same mechanism: TypeResolverMap bound the bare SubscriptionResolver, whose defaults are all unknown, so a typed subscription entry — resolve: (payload: Book) => payload.title — was rejected under strictFunctionTypes with Type 'unknown' is not assignable to type 'Book'. That is X6-4's defect surviving on the subscription arm.

subscribe is declared with method syntax (bivariant) and resolve reuses AnyFieldResolver, so a typed subscription assigns while an unannotated one still gets its parameters contextually. Instantiating SubscriptionResolver at never would buy the first and lose the second, which is the regression the field arm already hit.

Properties

Maps each emitted payload to the field value. Optional.

Methods

subscribe(
source: unknown,
args: Record<string, unknown>,
context: unknown,
info: unknown
): AsyncIterable<unknown> | Promise<AsyncIterable<unknown>>

Produces the event source for this subscription field.

Usage

import { type AnySubscriptionResolver } from "graphql-plugin/src/index.ts";