From a19520925fc95ba2374a309027faa1e84bf9cf9d Mon Sep 17 00:00:00 2001 From: Christian Holm Date: Tue, 21 Sep 2021 09:35:57 +0200 Subject: [PATCH] NestJS uses the class directly as the symbol --- src/index.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/index.ts b/src/index.ts index de35d7e..abff3c0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -81,11 +81,10 @@ export class DataLoaderInterceptor implements NestInterceptor { */ export const Loader = createParamDecorator( // tslint:disable-next-line: ban-types - (data: string | Function, context: ExecutionContext) => { - const name = typeof data === "string" ? data : data?.name; - if (!name) { + (data: Function, context: ExecutionContext) => { + if (!data) { throw new InternalServerErrorException( - `Invalid name provider to @Loader ('${name}')` + `No loader provided to @Loader ('${data}')` ); } @@ -96,13 +95,13 @@ export const Loader = createParamDecorator( } const ctx = GqlExecutionContext.create(context).getContext(); - if (!name || !ctx[NEST_LOADER_CONTEXT_KEY]) { + if (!ctx[NEST_LOADER_CONTEXT_KEY]) { throw new InternalServerErrorException( `You should provide interceptor ${DataLoaderInterceptor.name} globally with ${APP_INTERCEPTOR}` ); } - return ctx[NEST_LOADER_CONTEXT_KEY].getLoader(name); + return ctx[NEST_LOADER_CONTEXT_KEY].getLoader(data); } );