UNPKG

@webundsoehne/nestjs-graphql-typeorm-dataloader

Version:

A library to utilize the graphql-dataloader with nestjs and typeorm.

31 lines (28 loc) 978 B
import DataLoader from 'dataloader'; import { BatchLoadFn } from './batch-loader.interface.js'; import { KeyFunc } from './typeorm-loader-handler.interface.js'; import { TypeormLoaderOptions } from './typeorm-loader.interface.js'; import { TYPEORM_DATALOADER_EXTENSION_FIELD, CUSTOM_DATALOADER_EXTENSION_FIELD } from '../constants/extension-field.constants.js'; /** * A generic type to extend from for nestjs extensions. */ interface ExtensionType<T> { args: T; key: string | symbol; target: Function | object; } /** * Extension field definition for nest.js to store metadata of decorators. */ interface Extensions { [key: string]: any; [TYPEORM_DATALOADER_EXTENSION_FIELD]: ExtensionType<{ keyFunc: KeyFunc; options?: TypeormLoaderOptions; }>; [CUSTOM_DATALOADER_EXTENSION_FIELD]: ExtensionType<{ batchLoadFn: BatchLoadFn<any, any>; options?: DataLoader.Options<any, any, any>; }>; } export { Extensions };