UNPKG

@nestjs/graphql

Version:

Nest - modern, fast, powerful node.js web framework (@graphql)

77 lines 2.55 kB
import { GraphQLError } from 'graphql'; /** * Context passed to the "request start" hook. * @publicApi */ export interface GqlRequestStartHookContext { /** * Raw GraphQL document sent by the client (if available). */ query?: string; /** * Name of the operation being executed (if provided by the client). */ operationName?: string; /** * Variables sent along with the operation. */ variables?: Record<string, unknown>; /** * GraphQL context object associated with this request. */ context?: Record<string, unknown>; } /** * Context passed to the "request end" hook. * @publicApi */ export interface GqlRequestEndHookContext extends GqlRequestStartHookContext { /** * Errors collected during the execution of the operation (if any). */ errors?: readonly GraphQLError[]; /** * Value returned from the corresponding "request start" hook. * Useful to carry over instrumentation state (spans, timestamps, etc.). */ state?: unknown; } /** * @publicApi */ export type GqlRequestStartHook = (context: GqlRequestStartHookContext) => unknown; /** * @publicApi */ export type GqlRequestEndHook = (context: GqlRequestEndHookContext) => void; /** * @publicApi */ export declare class ResolverDecoratorHost { private decorator; private onRequestStartHook; private onRequestEndHook; setDecorator(decorator: (fn: (...args: unknown[]) => void) => (...args: unknown[]) => void): void; getDecorator(): (...args: unknown[]) => void; decorate(target: (...args: unknown[]) => void): (...args: unknown[]) => void; /** * Registers a hook that is called right before a GraphQL operation * starts being processed. Whatever it returns is passed back to the * "request end" hook through the `state` property. */ setOnRequestStartHook(hook: GqlRequestStartHook): void; getOnRequestStartHook(): GqlRequestStartHook; /** * Registers a hook that is called once a GraphQL operation has been * fully processed (right before the response is sent back to the client). */ setOnRequestEndHook(hook: GqlRequestEndHook): void; getOnRequestEndHook(): GqlRequestEndHook; /** * Indicates whether any of the request lifecycle hooks has been registered. */ hasRequestHooks(): boolean; onRequestStart(context: GqlRequestStartHookContext): unknown; onRequestEnd(context: GqlRequestEndHookContext): void; } //# sourceMappingURL=resolver-decorator-host.d.ts.map