Skip to content

Transform resolved fields in top-level query before responding #1361

Answered by kdaniel21
kdaniel21 asked this question in Q&A
Discussion options

You must be logged in to vote

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 combines BatchQueryExecutor (the class responsible for executing the BatchQuerys) and DataLoader. It simply calls dataLoader.load/loadMany, and initializes a DataLoader instance with (queries: BatchQuery[]) => this.batchQueryExecutor.executeQueries(queries), and disables caching. I can simply call graphqlBatchQueryExecutor

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kdaniel21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant