Skip to content

Commit

Permalink
chore(): Fix eslint issues for #618
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed Oct 23, 2020
1 parent 92171dc commit 460a9d5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/query-graphql/src/loader/dataloader.factory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { ExecutionContext } from '@nestjs/common';
import Dataloader from 'dataloader';

const cacheKeyFn = <K>(key: K): string => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return JSON.stringify(key, (_, v) => (typeof v === 'bigint' ? v.toString() : v));
};

export interface NestjsQueryExecutionContext extends ExecutionContext {
nestjsQueryLoaders?: Record<string, Dataloader<unknown, unknown>>;
}
Expand All @@ -21,10 +26,7 @@ export class DataLoaderFactory {
const nestjsQueryLoaders = this.initializeContext(context);
if (!nestjsQueryLoaders[name]) {
// eslint-disable-next-line no-param-reassign
nestjsQueryLoaders[name] = new Dataloader(handler, {
cacheKeyFn: (key) =>
JSON.stringify(key, (_, v) => (typeof v === 'bigint' ? v.toString() : v)),
});
nestjsQueryLoaders[name] = new Dataloader(handler, { cacheKeyFn });
}
return nestjsQueryLoaders[name] as Dataloader<K, V>;
}
Expand Down

0 comments on commit 460a9d5

Please sign in to comment.