dataloader too many reqs?

node v8.17.0
version: master
endpointsharetweet
const Dataloader = require('dataloader'); const delay = (x, t = 1500) => new Promise(r => { if (x) console.log('delay: ' + x); setTimeout(r, t, x); }); const dataloader = new Dataloader(keys => Promise.all(keys.map(key => delay(key)))); dataloader.load(1) .then(async firstUser => { // Later… await delay(undefined, 2500); Promise.all([ dataloader.load(1), dataloader.load(2) ]).then(console.log); await delay(undefined, 200); dataloader.load(1) .then(u => { console.log('__1: ' + u); dataloader.load(2).then(u => console.log('____2: ' + u)) }) await delay(undefined, 2000); dataloader.load(2) .then(u => { console.log('__2: ' + u); dataloader.load(1).then(u => console.log('____1: ' + u)) }) })
Loading…

no comments

    sign in to comment