You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to use Dataloader with await's, but the problem is that batching doesn't work, I guess it has something to do with ticks & event loop. Could someone give me a working example where I could use await's to call load() functions so that it would still use batching?
A simple test.js script:
constDataLoader=require('dataloader')consttestLoader=newDataLoader((ids)=>{console.log('testLoader',ids)returnPromise.resolve(ids)})constdummyFunction=async()=>{awaittestLoader.load(1)// <--- DOES NOT BATCHawaittestLoader.load(2)awaitPromise.all([testLoader.load(3),testLoader.load(4)])// <-- BATCHES};(async()=>{awaitdummyFunction()})()
You cannot expect batching to work in your scenario. To understand better, you can ask this question "What if first await's result is needed in the following?"
I'd like to use Dataloader with await's, but the problem is that batching doesn't work, I guess it has something to do with ticks & event loop. Could someone give me a working example where I could use await's to call load() functions so that it would still use batching?
A simple test.js script:
output:
I have a async Express handler function where I'd like to use loader with await's to load stuff from DB, so really basic stuff.
Any tips appreciated!
The text was updated successfully, but these errors were encountered: