Fix value cache batch loader environment#278
Draft
andimarek wants to merge 4 commits into
Draft
Conversation
This file contains hidden or 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
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.
This is a demonstration patch stacked on top of #277. It addresses the
BatchLoaderEnvironmentsemantic regression described in the requested-changes review.Problem
#277 builds a
BatchLoaderEnvironmentbefore value-cache filtering. If a dispatch has a partialValueCachehit, the actual batch loader is invoked only with the missed keys, but the environment can still describe the original full key/context list.That breaks the existing invariant that
environment.getKeyContextsList()is aligned with thekeysargument received by aBatchLoaderWithContext.Fix
When
ValueCachefiltering producesmissedKeys, build a freshBatchLoaderEnvironmentfrommissedKeysandmissedKeyContextsbefore invoking the concrete batch loader.The actual fix is intentionally small:
src/main/java/org/dataloader/DataLoaderHelper.java:483buildsmissedEnvironmentfrommissedKeysandmissedKeyContexts.src/main/java/org/dataloader/DataLoaderHelper.java:484passesmissedEnvironmentinto the concreteinvokeLoader(...)call for the cache misses.GitHub line link:
https://github.com/graphql-java/java-dataloader/blob/fix-pr-277-value-cache-environment/src/main/java/org/dataloader/DataLoaderHelper.java#L483-L484
Test
Adds a regression test where:
Ais returned fromValueCacheBmisses and is sent to the batch loaderBenvironment.getKeyContextsList().get(0)matchesB's context, notA'sThe key test lines are:
src/test/java/org/dataloader/DataLoaderBatchLoaderEnvironmentTest.java:221-249GitHub line link:
https://github.com/graphql-java/java-dataloader/blob/fix-pr-277-value-cache-environment/src/test/java/org/dataloader/DataLoaderBatchLoaderEnvironmentTest.java#L221-L249
Verification
./gradlew test --tests org.dataloader.DataLoaderBatchLoaderEnvironmentTest./gradlew testgit diff --check origin/pr/277