Created
March 18, 2018 05:55
-
-
Save cauldyclark15/bb51c90c277af8aeba2810bc36bb1936 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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