-
Notifications
You must be signed in to change notification settings - Fork 96
Description
I currently have a use case in my app that looks l like this: someone is trying to use our GraphQL API like a batch REST API. My recommendation is to do something like this:
query batchGetMyItems($Input1: Input!, $input2: Input!, ...) {
item1: item(input: $input1) {
// fields
}
item2: item(input: $input1) {
// fields
}
....
}
In the service serving the relevant subgraph, we want to implement dataloaders to turn this into a batch call rather than individual resolver calls. I've done a POC (that I can't share here) that accomplishes this, but relies on a ScheduledDataLoaderRegistry to wait x number of milliseconds to aggregate all of these inputs before dispatching the request.
But, we know at call time how many of these we should be waiting for, so ideally we would dispatch after all inputs have been processed and prepared for fetching. What I'd like to propose is a function that does something like this:
dataLoader.getQueueLength()
That returns the current queue length for a data loader, which we can use to dispatch once we know we've collected all items.
I've scoured documentation and played with the library, is there a way to currently accomplish this? Is it a feature worth adding?
Thanks!