Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
⚡️ DataLoader #722
Add DataLoader support
DataLoader is a concept of batching and caching within requests to reduce the number of underlying database queries needed to fetch the required data.
In GraphQL, it's common that resolvers lead to a n+1 problem, where one query is executed, then "n" more queries are executed to resolve the connected objects.
WPGraphQL was largely guilty of this problem.
Take the following query as an example:
This would execute 1 query to get the 10 posts, then 10 queries to get the author for Post 1, Post 2, etc
With this PR, this would execute 2 queries.
The first query would execute to get the posts, then the
Prior to this PR, we had an initial implementation for Deferred resolvers for post authors, but that was the only place we were making use of this concept of Deferred resolvers for batch queries.
Now, it's implemented pretty much everywhere. There are other improvements as well, so even the DataLoader setup for authors is more efficient than it was previously.
Here are some before/after examples showing the improvements: