dataloader
dataloader copied to clipboard
[QUESTION] Why aren't keys being de-duplicated even when the cache is disabled?
Is there a reason why DataLoader doesn't deduplicate ids provided to the batch function when the cache is set to false?
const dataloader1 = new DataLoader(async function loadMany(ids) {
// [[1],[2],[3],[4],[5],[1],[2],[3],[4],[5]]
console.log(ids)
return ids
}, {
cacheKeyFn: (id) => id[0],
cache: false
})
const ids = [[1],[2],[3],[4],[5],[1],[2],[3],[4],[5]]
ids.forEach(id => dataloader1.load(id))
//--
const dataloader2 = new DataLoader(async function loadMany(ids) {
// [[1],[2],[3],[4],[5]]
console.log(ids)
return ids
}, {
cacheKeyFn: (id) => id[0],
})
const ids = [[1],[2],[3],[4],[5],[1],[2],[3],[4],[5]]
ids.forEach(id => dataloader2.load(id))
I'm not sure if this would be a feature request or if it would be considered a bug? Or am I missing something that prevents us from de-duplicating the keys provided to the batch function? :)