import DataLoader from 'dataloader'; import { GraphQLResolveInfo } from 'graphql'; import { BaseEntity, ObjectType } from 'typeorm'; import type { PrimaryKey } from '../common'; import type { DefaultRegisteredLoaders } from './context'; export interface DataLoaderFunction { load: ((id?: PrimaryKey) => Promise) & ((ids?: PrimaryKey[]) => Promise); } export declare function loader(entity: typeof BaseEntity, opts?: { isPublished?: boolean; loadRelationIds?: boolean; }): DataLoaderFunction; export declare class DataloaderCleaner { static redisLoaders: Record; static reg(segment: string, loader: any): void; static clear(segment: string, id: PrimaryKey): void; } export declare class GenericDataLoader { static _loaders: any; constructor(); static loaders(): Loaders; initLoaders(loaders: T): void; createLoaders(): T; } export declare function cachedDataLoader(segment: string, fn: any): DataLoader; export declare function cachedPerRequestDataLoader(segment: string, fn: any): DataLoader; /** * 解析出 graphql 参数中的关联字段 */ export declare function resolveRelationsFromInfo(info: GraphQLResolveInfo, path: string): boolean | { relations?: string[]; disableMixedMap?: boolean; }; export declare function resolveSelectsFromInfo(info: GraphQLResolveInfo, path: string): string[] | null; export declare const resolveFieldsByPagedMixInfo: (entity: ObjectType, info: GraphQLResolveInfo) => { mixedFields: string[]; relations: boolean | { relations?: string[]; disableMixedMap?: boolean; }; select: (keyof Entity)[]; }; export declare const resolveFieldsByPagedInfo: (entity: ObjectType, info: GraphQLResolveInfo) => { relations: boolean | { relations?: string[]; disableMixedMap?: boolean; }; select: (keyof Entity)[]; };