import { GraphQLFieldConfig, GraphQLFieldConfigArgumentMap, GraphQLFieldResolver, GraphQLOutputType, GraphQLResolveInfo } from "graphql"; import { Operation } from "./Operation"; import { OperationMapping } from "./OperationMapping"; import { OperationResolver } from "./OperationResolver"; import { MaybePaginatedResolveInfoVisitor } from "./PaginatedResolveInfoVisitor"; import { ResolverContext } from "./ResolverContext"; import { Interceptor } from "./utils/util-types"; import { OperationType } from "./operation-types"; declare type FieldConfigInterceptor = Interceptor>; /** * Base class for operations that interact with one or more GRelDAL data sources. */ export declare abstract class MappedOperation implements Operation { readonly mapping: OperationMapping; /** * Distinguishes whether the operation is a query, mutation or subscription */ abstract operationType: OperationType; /** * Currently attached operation interceptors */ private interceptors; private interceptedFieldConfig?; constructor(mapping: OperationMapping); /** * Default argument mapping for operation * * Can be overriden in Operation mapping configuration. */ abstract get defaultArgs(): GraphQLFieldConfigArgumentMap; /** * GraphQL output type for the result of the operation */ abstract get type(): GraphQLOutputType; /** * Retrieve default resolver for the operation. * * A resolver specified in operation mapping will take precedence */ abstract defaultResolver(ctx: any): OperationResolver; /** * Construct resolver context used to instantiate the resolver */ createResolverContext(source: any, args: TArgs, context: any, resolveInfo: GraphQLResolveInfo, _resolveInfoVisitor?: MaybePaginatedResolveInfoVisitor): Promise>; /** * GraphQL field configuration used to expose the operation. * * This field configuration can be intercepted through a chain of * interceptors before it surfaces to the GraphQL API. */ get rootFieldConfig(): GraphQLFieldConfig; /** * Get final field config after passing the root field configuration * through a chain of interceptors */ get fieldConfig(): GraphQLFieldConfig; /** * Whether the operation interacts with multiple data sources */ get supportsMultipleDataSources(): boolean; /** * Whether multiple resolvers are supported */ get supportsMultipleResolvers(): boolean; /** * Mapped argument specifications for the operation */ get mappedArgs(): GraphQLFieldConfigArgumentMap; /** * Name of operation */ get name(): string; /** * Whether the operation reaches into connected entities through associations */ get shallow(): boolean; /** * Whether the operation resolves to a single entity */ get singular(): boolean; /** * Mapped arguments for the operation */ get args(): import("./MappedArgs").MappedArgs | undefined; /** * Getter to obtain the Type of arguments at type level. * * Throws if invoked at runtime. */ get ArgsType(): TArgs; /** * Attach an interceptor to the current queue of interceptors. * * Interceptors can transform how the operation is handled. They can change * the arguments, add validations, log results before or after resolution * or entirely bypass the downstream resolution flow. * * @param interceptor A function that receives the current field configuration * and returns a new field configuration. */ intercept(interceptor: FieldConfigInterceptor): void; /** * Intercept operation resolution with a higher order function. * * Essentially a convenience wrapper over intercept for the common case when * we care about intercepting just the resolver and not the complete field configuration. * * @param interceptor A function that receives the current resolver and returns * a new resolver which will be called when the operation is invoked. * * It is the responsibility of interceptor to invoke the received (old) resolver * unless a complete bypass is intended. */ interceptResolve(interceptor: Interceptor>): void; /** * Clone the operation with an independent queue of interceptors * * Unless list of interceptors is specified, the cloned operation will inherit * current queue of interceptors. */ deriveIndependentlyInterceptable(interceptors?: Interceptor>[]): MappedOperation; /** * Retrieve resolver for the operation. * * This will typically be the default resolver for the operation, but * can be overriden in the operation mapping */ getResolver(resolverContext: ResolverContext, any, TArgs>): { resolver: any; resolverId: string; }; /** * Wrap result in array if we are supposed to return multiple values. * Unwrap result array if singular result is expected. * * This enables us to write resolvers (esp. those that will only ever return * a single entity) that don't care whether result is singular or plural. */ normalizeResultsForSingularity(result: any): any; /** * * @param source * @param args * @param context * @param resolveInfo * @param resolveInfoVisitor */ resolve(source: any, args: TArgs, context: any, resolveInfo: GraphQLResolveInfo, resolveInfoVisitor?: MaybePaginatedResolveInfoVisitor, interceptResolver?: Interceptor>): Promise; } export {};