Skip to content

Commit

Permalink
add: context in generateDataLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
Jo committed Feb 7, 2020
1 parent a2f4b96 commit 808f52b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import { Observable } from 'rxjs';
export interface NestDataLoader<ID, Type> {
/**
* Should return a new instance of dataloader each time
* @params ctx: the execution context
*/
generateDataLoader(): DataLoader<ID, Type>;
generateDataLoader(ctx: any): DataLoader<ID, Type>;

This comment has been minimized.

Copy link
@krislefeber

krislefeber Feb 7, 2020

Owner

This is going to break existing functionality. This should at minimum be optional

}

/**
Expand Down Expand Up @@ -49,7 +50,7 @@ export class DataLoaderInterceptor implements NestInterceptor {
try {
ctx[type] = this.moduleRef
.get<NestDataLoader<any, any>>(type, { strict: false })
.generateDataLoader();
.generateDataLoader(ctx);
} catch (e) {
throw new InternalServerErrorException(`The loader ${type} is not provided`);
}
Expand Down

0 comments on commit 808f52b

Please sign in to comment.