-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Optimize repeated apollo-cache-inmemory reads by caching partial query results. #3394
Merged
Merged
Changes from 72 commits
Commits
Show all changes
97 commits
Select commit
Hold shift + click to select a range
2423c22
Disable auto-git-add behavior.
benjamn 4c0aacf
Implement graphql-anywhere functionality with local module.
benjamn 7876276
Move readStoreResolver from readFromStore.ts into graphql.ts.
benjamn ea76ac7
Rename src/graphql.ts to src/queryStore.ts.
benjamn fa2e1d3
Import FragmentMatcher from src/queryStore.ts.
benjamn e312a47
Move resultMapper function into queryStore.ts.
benjamn 2017ff7
Eliminate unnecessary ExecOptions type.
benjamn 55ad717
Rename queryStore to executeStoreQuery.
benjamn a537d24
Move ID_KEY declaration/export into executeStoreQuery.ts.
benjamn 36a330f
Simplify and stop exporting Exec{Context,Info} types.
benjamn 27d764e
Use ExecResult return type to avoid mutating context.hasMissingField.
benjamn 3352240
Lock down ReadStoreContext properties to prevent errant mutations.
benjamn f102b3c
Remove unnecessary fragmentMap parameter from writeQueryToStore.
benjamn db22efd
Make all WriteContext members read-only.
benjamn 4621f4c
Miscellaneous simplifications to store-writing functions.
benjamn 8200d31
Get rid of NormalizedCacheFactory abstraction.
benjamn 241ea87
Return early if shouldInclude(selection, variables) returns false.
benjamn b778044
Reimplement writeQueryToStore in terms of writeResultToStore.
benjamn e449625
Don't wait to call mergeWithGenerated until end of writeFieldToStore.
benjamn 2f13741
Stop needlessly creating new NormalizedCache objects.
benjamn 8327aac
Introduce OptimisticObjectCache to track data usage and invalidation.
benjamn 01261fa
Enable OptimisticObjectCache as the default NormalizedCache.
benjamn 36b3226
Declare defaultFragmentMatcher function once in exportStoreQuery.ts.
benjamn 5ccd33c
Cache outermost executeStoreQuery results.
benjamn 4225046
Apply optimistic caching to executeSelectionSet, too.
benjamn dfe7c61
Apply optimistic caching to executeField, too.
benjamn 3b7c330
Give wrapped cached functions names for easier debugging.
benjamn a8e9127
Lift all returnPartialData logic into diffQueryAgainstStore.
benjamn 5b5c6bf
Tolerate tolerable missing fields.
benjamn b2ea041
Fully remove returnPartialData property from ReadStoreContext.
benjamn 106ac99
Lift all previousResult logic out of executeStoreQuery.
benjamn 36182fd
Revert "Apply optimistic caching to executeField, too."
benjamn 05e13f5
Rename OptimisticObjectCache to DepTrackingCache.
benjamn 7ac6023
Add a brief CHANGELOG entry to pacify the Danger bot.
benjamn 479c5d6
Completely remove unnecessary ID_KEY Symbol.
benjamn db55d27
Bump apollo-cache-inmemory npm version to 1.3.0-beta.0.
benjamn dcef720
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 1cefd61
Bump apollo-cache-inmemory npm version to 1.3.0-beta.1.
benjamn 047e976
Abandon merge if source === target.
benjamn da6e7b7
Bump apollo-cache-inmemory npm version to 1.3.0-beta.2.
benjamn b3242f2
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn e1e1360
Tolerate frozen objects when merging properties in executeStoreQuery.
benjamn 7578cec
Bump apollo-cache-inmemory npm version to 1.3.0-beta.3.
benjamn 847411a
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 8721375
Update optimism dependency of apollo-cache-inmemory to version 0.6.5.
benjamn e00f0b4
Bump apollo-cache-inmemory npm version to 1.3.0-beta.4.
benjamn d981e56
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn a07b33d
Fix bogus OptimisticWrapperFunction import path in executeStoreQuery.…
benjamn b00a3e1
Convert __tests__/roundtrip.ts from CRLF to LF line endings.
benjamn 3909ab6
Verify DepTrackingCache caching behavior in every roundtrip.ts test.
benjamn 33d8362
Bump apollo-cache-inmemory npm version to 1.3.0-beta.5.
benjamn f29970a
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 74e0b29
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 00347ca
Make optimistic depend function a private member of DepTrackingCache.
benjamn e38a3eb
Convert src/types.ts from CRLF to LF line endings.
benjamn 0eca85b
Merge executeStoreQuery.ts into readFromStore.ts.
benjamn 4481349
Introduce StoreReader class for reading and diffing.
benjamn 5c02c6c
Move cached executeStoreQuery function into StoreReader class.
benjamn 09cbca7
Move execute{SelectionSet,Field,SubSelectedArray} into StoreReader cl…
benjamn 1acbef6
Inline defaultFragmentMatcher function.
benjamn 7b7ba9a
Bump apollo-cache-inmemory npm version to 1.3.0-beta.6.
benjamn 3d8f8a5
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn a3cc100
Make apollo-client depend on apollo-cache-inmemory@1.3.0-beta.6.
benjamn 8d3770a
Make apollo-boost depend on apollo-cache-inmemory@1.3.0-beta.6.
benjamn 5e0fdda
Avoid broadcasting watches when nothing has changed.
benjamn d962de4
Bump apollo-cache-inmemory npm version to 1.3.0-beta.7.
benjamn 2debf6a
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 274a730
Disable nonsensical tslint prepare step.
benjamn fcbf844
Bump apollo-cache-inmemory npm version to 1.3.0-beta.8.
benjamn 05a13ee
Replace file:... versions in apollo-cache-inmemory/package.json.
benjamn 3cf8e16
Bump apollo-cache-inmemory npm version to 1.3.0-beta.9.
benjamn 3a0365d
Run `npm install` in subpackages instead of just `prepare`.
benjamn c148dcd
Revert "Avoid broadcasting watches when nothing has changed."
benjamn 12d5db6
Bump apollo-cache-inmemory npm version to 1.3.0-beta.10.
benjamn c03924c
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn b63eed0
Avoid broadcasting watches when nothing has changed, again.
benjamn 4577534
Bump apollo-cache-inmemory npm version to 1.3.0-beta.11.
benjamn a388457
Convert apollo-cache-inmemory/CHANGELOG.md from CRLF to LF line endings.
benjamn ce4ce65
Note PR #3394 in CHANGELOG.md.
benjamn 84fad50
Dirty maybeBroadcastWatch after any optimistic broadcast.
benjamn ee45dec
Bump apollo-cache-inmemory npm version to 1.3.0-beta.13.
benjamn 6aa0d02
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 0eea6f7
Move writeToStore.ts functions into a StoreWriter class.
benjamn c453e75
Use simple string as cache key for DepTrackingCache#depend.
benjamn 45c4169
Reduce WeakMap usage by not using optimism defaultMakeCacheKey.
benjamn 994cc67
Avoid WeakMap for InMemoryCache#transformDocumentCache.
benjamn 8be655f
Bump apollo-cache-inmemory npm version to 1.3.0-beta.14.
benjamn ff66a02
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 2170266
Add generic KeyType parameter to CacheKeyNode class.
benjamn acd2a67
Stop using InMemoryCache#transformDocument internally.
benjamn 4a44a41
Allow structurally identical (sub)queries to share the same cache keys.
benjamn dcb8603
Be much more careful about calling cache.set in mergeWithGenerated.
benjamn 6809e3d
Call store.set in writeFieldToStore only if new field value differs.
benjamn 35cecb1
Bump apollo-cache-inmemory npm version to 1.3.0-beta.15.
benjamn ac82fdb
Merge branch 'master' into benjamn/cache-result-objects-with-optimism
benjamn 8609fb6
Revert a few changes I made for my own convenience in PR #3394.
benjamn 03a1236
Update apollo-cache-inmemory/package-lock.json.
benjamn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hwillson This did fix my tests (which were previously failing because
jest
could not resolve theoptimism
dependency ofapollo-cache-inmemory
). Perhaps we should consider cherry-picking this change ontomaster
, until this PR is merged?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, on second thought, the Netlify deploy now seems to be failing when this command runs
npm install
inpackages/apollo-boost
, so I guessnpm install
has some drawbacks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing @benjamn - a lot of the
scripts
can be streamlined further for sure. Right nowprepare
is also doing a first time build in child packages; do you think we should preserve that? If so we could maybe consider keeping this aslerna run prepare
and instead modify theprepare
script in each child package to benpm install && npm run build
(we can drop the linting if we want, keeping it as optional).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I just posted before seeing your second message. There's a combination of steps lurking here that should iron this all out for the better. I'll take a look as well. Thanks!