UNPKG

@nestjs/graphql

Version:

GraphQL for NestJS: code-first and schema-first APIs, resolvers as providers, subscriptions, federation and generated SDL, on Apollo or Mercurius.

110 lines • 6.04 kB
import { MetadataScanner, ModuleRef, ModulesContainer } from '@nestjs/core'; import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator.js'; import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js'; import { Module } from '@nestjs/core/injector/module.js'; import { SerializedGraph } from '@nestjs/core/inspector/serialized-graph.js'; import { SubscriptionOptions } from '../decorators/subscription.decorator.js'; import { AbstractGraphQLDriver } from '../drivers/abstract-graphql.driver.js'; import { GqlModuleOptions } from '../interfaces/index.js'; import { ResolverMetadata } from '../interfaces/resolver-metadata.interface.js'; import { BaseExplorerService } from './base-explorer.service.js'; import { ResolverDecoratorHost } from './resolver-decorator-host.js'; export declare class ResolversExplorerService extends BaseExplorerService { private readonly modulesContainer; private readonly metadataScanner; private readonly externalContextCreator; private readonly gqlOptions; private readonly moduleRef; private readonly serializedGraph; private readonly resolverDecoratorHost; private readonly logger; private readonly gqlParamsFactory; private readonly injector; private coreModuleRef; private fieldResolverEnhancersLookup; private hasGlobalFieldMiddleware; constructor(modulesContainer: ModulesContainer, metadataScanner: MetadataScanner, externalContextCreator: ExternalContextCreator, gqlOptions: GqlModuleOptions, moduleRef: ModuleRef, serializedGraph: SerializedGraph, resolverDecoratorHost: ResolverDecoratorHost); explore(): Record<string, Record<string, Function | Record<string, any>>>; filterResolvers(gqlAdapter: AbstractGraphQLDriver, wrapper: InstanceWrapper, moduleRef: Module): ResolverMetadata[]; createContextCallback<T extends Record<string, any>>(instance: T, prototype: any, wrapper: InstanceWrapper, moduleRef: Module, resolver: ResolverMetadata, isRequestScoped: boolean, transform?: Function): any; /** * Rewrites the incoming arguments object onto the property names declared by * the `@ArgsType()`/`@InputType()` classes of the method before the resolver * context (and therefore any pipe, global ones included) runs. */ private withMappedArgs; createSubscriptionMetadata(gqlAdapter: AbstractGraphQLDriver, createSubscribeContext: Function, subscriptionOptions: SubscriptionOptions, resolverMetadata: ResolverMetadata, instanceRef: Record<string, any>): { callback: { subscribe: any; resolve: (payload: unknown, args: unknown, context: unknown, info: unknown) => any; }; name: string; type: string; methodName: string; }; getAllCtors(): Function[]; private mapToCtor; /** * Builds the exceptions handler for errors thrown while a request-scoped * resolver (or one of its dependencies) is being instantiated, which happens * before the filter-wrapped callback exists. Mirrors the HTTP router * (`RouterExplorer#createRequestScopedHandler` in `@nestjs/core`). * * `ExternalContextCreator` does not expose its exception filter context, so * it is reached through a private field. Returns `null` (the error is then * rethrown as is) if that field is missing or has an unexpected shape. */ private createCreationErrorHandler; private registerContextProvider; private registerFieldMiddlewareIfExists; /** * Middleware of a field resolver method: the `middleware` option of * `@ResolveField()` followed by the middleware applied with `@UseFieldMiddleware()`. */ private getFieldResolverMiddleware; /** * Determines if a field resolver can use the fast-path that bypasses * ExternalContextCreator overhead. This is possible when: * - No guards/filters/interceptors are enabled for field resolvers * - No field middleware is registered (global or method-level) * - No parameter decorators (@Parent, @Args, etc.) are used on the method */ private canUseFastFieldResolver; /** * Whether the handler resolves a field of a root operation type rather than * one of an object or interface type. The name of the type is not enough to * tell: a code first object type can be named like a root type (e.g., a * billing "Subscription"), and its resolver then declares it with a class. */ private isRootTypeHandler; /** * A "@Subscription()" handler or, in a schema first resolver of the * "Subscription" type, any handler. */ private isSubscriptionHandler; private getContextOptions; /** * `ExternalContextCreator` silently leaves out an enhancer it cannot * resolve, so a handler would run without guards, interceptors, pipes or * filters it declares. Fail at startup instead when: * - an enhancer is referenced by class, but Nest did not register it for * the provider: it does so when scanning a module, only for providers * declared as a class (directly or through `useClass`), and not for those * created with `useFactory` or `useValue`; * - a request or transient-scoped global enhancer applies, but the provider * is not an entry provider, the only ones Nest binds those enhancers to. * A provider is one when the class, the token or the `useClass` class of * the provider is decorated with `@Resolver()`. */ private assertEnhancersCanRun; /** * Whether `ExternalContextCreator` finds an instance of the enhancer for a * handler of the provider: it looks it up in the module of the provider, * where Nest registered it either for this provider (and so created the * instances it needs, whatever its scope) or, if it is static, for another * provider of the module. */ private isEnhancerBound; private assignResolverConstructorUniqueId; } //# sourceMappingURL=resolvers-explorer.service.d.ts.map