-
Hey! First of all, I really appreciate your work with this library, and I also appreciate that I can ask here knowing that you'll likely help out, even if it's not strictly a bug/feature request. :) I'm facing a situation where I need a "lookahead" functionality, which I can use to transform the the final object before returning. Consider the following query:
To resolve As you might see, with batching, I could decrease the n*2 complexity (n = the number of Combining the queries here is not the hard part as in the implementation I can just return a At first, I was fairly certain that I can simply achieve this with a traditional middleware, yet, no success. I also tried The closest I got was basically writing an own helper function that uses the I've used I really wonder whether you have any idea in mind that would neatly solve this problem. I hope that my description was clear, even though I didn't create a sandbox. If you've got any further questions, I'd be glad to answer them, or also come up with a simple reproduction. Thanks for taking the time! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After stepping back a little bit from the problem, I started looking into Hence, I ended up solving the problem by just adding a I hope it will be useful for somebody in the future, even if their problem domain is slightly different. But feel free to drop a comment here, I might be able to help! |
Beta Was this translation helpful? Give feedback.
After stepping back a little bit from the problem, I started looking into
DataLoader
again. Initially, I wanted to create some custom implementation for the batching based on theirs. Yet, I realized that it is not needed, I can simply use data loader with caching disabled.Hence, I ended up solving the problem by just adding a
graphqlBatchQueryResolver
to the context, that combinesBatchQueryExecutor
(the class responsible for executing theBatchQuery
s) andDataLoader
. It simply callsdataLoader.load
/loadMany
, and initializes aDataLoader
instance with(queries: BatchQuery[]) => this.batchQueryExecutor.executeQueries(queries)
, and disables caching. I can simply callgraphqlBatchQueryExecutor