I have an application with Auth0 and graphQl.
I use dataloaders to batching requests to DB. https://github.com/graphql/dataloader
For example, fetching data from DB looks like:
// Booking is Mongoose model
new DataLoader(
bookingIds => Booking.find({ _id: { $in: bookingIds } }),
);
And now I need to fetch data about group of users. Of course, I can write
// getUser is ManagementClient.getUser from 'auth0' package
new DataLoader(
userIds => Promise.all(
userIds.map(
id => getUser({ id }),
),
),
)
This solution is slowly. Can I get data of collection of users by one request?