Skip to content

Commit

Permalink
Merge pull request #4 from jean-leonco/chore/prime-cache
Browse files Browse the repository at this point in the history
chore(prime-cache): add missing prime function to createLoader
  • Loading branch information
jean-leonco authored Jan 6, 2021
2 parents 61aa78a + c93222d commit 1d24dcb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/createLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ export const createLoader = <

const clearCache = ({ dataloaders }: Context, id: string) => dataloaders[loaderName].clear(id.toString());

const primeCache = ({ dataloaders }: Context, id: string, data: Value) =>
dataloaders[loaderName].prime(id.toString(), data);

const clearAndPrimeCache = (context: Context, id: string, data: Value) =>
clearCache(context, id) && primeCache(context, id, data);

const loadAll = withConnectionCursor(model, load, (context: Context, args: FilteredConnectionArguments) => {
const builtMongoConditions = buildMongoConditionsFromFilters(context, args.filters, filterMapping as any);

Expand All @@ -105,6 +111,8 @@ export const createLoader = <
},
getLoader,
clearCache,
primeCache,
clearAndPrimeCache,
load,
loadAll,
};
Expand Down

0 comments on commit 1d24dcb

Please sign in to comment.