-
-
Notifications
You must be signed in to change notification settings - Fork 810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce batch delegation #1735
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest changes of this PR are available as alpha in npm: Quickly update your package.json by running:
|
= memoize info using info.fieldNodes, which is memoized by upstream graphql-js = refactor StitchingInfo type and handleObject and supporting methods to use consistent keys to enable memoization
Add key option within type merging config to enable batch loading for lists. This minimal version of batching uses cached dataLoaders to create a separate batch for each list rather than for every similar query within the resolution tree. This is because a new dataloader is created for every new info.fieldNodes object, which is memoized upstream by graphql-js within resolution of a given list to allow the loader to be used for items of that list. A future version could provide an option to batch by similar target fieldName/selectionSet, but this version may hit the sweet spot in terms of code complexity and batching behavior. see: #1710
remove unused isProxiedResult function move unwrapResult and dehoistResult into createMergedResolver WrapFields and HoistField transforms now use their own unwrapping and dehoisting logic, so these functions should be located only to the file that used them
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add ability to create a batchDelegate function that uses a dataloader scoped to each member of a list to batch delegateToSchema calls.
Adds option within type merging to retrieve additional fields for objects via a root field that returns a list instead of a particular item, using a batchDelegate function, see #1710
Fixes memoization (as initially introduced in #1728). Cache misses were occurring because of mistakes within the memoization algorithm as well as the functions not providing static keys.