Skip to content

Instantly share code, notes, and snippets.

@cauldyclark15
Created March 18, 2018 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cauldyclark15/bb51c90c277af8aeba2810bc36bb1936 to your computer and use it in GitHub Desktop.
Save cauldyclark15/bb51c90c277af8aeba2810bc36bb1936 to your computer and use it in GitHub Desktop.
import DataLoader from 'dataloader';
import InventoryItemService from './InventoryItemService';
const cache = String(process.env.CACHE).toLowerCase() === 'true';
const inventoryItemService = new InventoryItemService();
export const inventoryItem = new DataLoader(
keys => Promise.all(keys.map(inventoryItemService.findById)),
{ cache },
);
export const inventoryItemEvents = new DataLoader(
keys => Promise.all(keys.map(inventoryItemService.getEvents)),
{ cache },
);
export const nextAvailableInventoryItemNumbers = new DataLoader(
keys =>
Promise.all(
keys.map(inventoryItemService.getNextAvailableInventoryItemNumbers),
),
{ cache },
);
export const nextAvailableInventoryItemNumber = new DataLoader(
keys =>
Promise.all(
keys.map(
inventoryItemService.getNextAvailableInventoryNumberByInventoryTypeId,
),
),
{ cache },
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment