@pothos/plugin-dataloader
Version:
A Pothos plugin for attaching dataloader to object types
11 lines (10 loc) • 1.57 kB
TypeScript
import { type MaybePromise, type SchemaTypes } from '@pothos/core';
import DataLoader, { type Options } from 'dataloader';
import type { GraphQLResolveInfo } from 'graphql';
export declare function rejectErrors<T>(val: MaybePromise<readonly (Error | T)[]>): MaybePromise<(Promise<T> | T)[]>;
export declare function loadAndSort<K, V, C, LoadResult, Args = never>(load: (keys: K[], context: C, args: Args, info: GraphQLResolveInfo) => MaybePromise<LoadResult>, toKey: false | ((val: V) => K) | undefined): ((keys: K[], context: C, args: Args, info: GraphQLResolveInfo) => MaybePromise<LoadResult>) | ((keys: K[], context: C, args: Args, info: GraphQLResolveInfo) => Promise<(V | null)[]>);
export declare function dataloaderGetter<K, V, C>(loaderOptions: Options<K, V, C> | undefined, load: (keys: K[], context: SchemaTypes["Context"]) => Promise<readonly (Error | V)[]>, toKey: ((val: V) => K) | undefined, sort: boolean | ((val: V) => K) | undefined): import("@pothos/core").ContextCache<DataLoader<K, V, C>, object, [
]>;
export declare function pathDataloaderGetter<K, V, C, Args>(loaderOptions: Options<K, V, C> | undefined, load: (keys: K[], context: SchemaTypes["Context"], args: Args, info: GraphQLResolveInfo) => Promise<readonly (Error | V)[]>, toKey: ((val: V) => K) | undefined, sort: boolean | ((val: V) => K) | undefined, byPath?: boolean): (args: Args, ctx: SchemaTypes["Context"], info: GraphQLResolveInfo) => DataLoader<K, V, C>;
export declare function cacheKey(path: GraphQLResolveInfo["path"] | undefined): string;
//# sourceMappingURL=util.d.ts.map