Skip to content
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

Release 3.4.0 #7399

Merged
merged 454 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
454 commits
Select commit Hold shift + click to select a range
fd8a94c
Basic tests of client.refetchQueries API.
benjamn May 11, 2021
e02f8a1
Refetch updateCache-triggered queries if onQueryUpdated not provided.
benjamn May 11, 2021
967ade3
Add a few TODOs to client.refetchQueries test file.
benjamn May 12, 2021
dfe9e68
Make dirtying of removed EntityStore Layer fields more precise.
benjamn Jan 12, 2021
bee43b0
Test client.refetchQueries({ optimistic: true }).
benjamn May 12, 2021
70bd843
Move refetchQueries-related types into src/core/types.ts.
benjamn May 13, 2021
b75bd7d
Infer better refetchQueries return type from onQueryUpdated return type.
benjamn May 13, 2021
30139fc
Improve comments about IsStrictlyAny<T> and related types.
benjamn May 13, 2021
028fd75
Use interface instead of type for RefetchQueriesResult<TResult>.
benjamn May 13, 2021
8ccfbb2
Add a test of returning true from onQueryUpdated.
benjamn May 13, 2021
b000064
Add a test of returning false from onQueryUpdated.
benjamn May 13, 2021
dcb8288
Clarify remaining TODO about testing no-cache with refetchQueries.
benjamn May 13, 2021
0c3fad6
Failing test of using updateCache and returning true from onQueryUpda…
benjamn May 13, 2021
c948655
Inline maybeAddResult helper function.
benjamn May 13, 2021
01b13c7
Store both lastDiff and diff in includedQueriesById.
benjamn May 13, 2021
75e455c
Fix failing test of updateCache with onQueryUpdated returning true.
benjamn May 14, 2021
311f692
Use fewer forced typecasts in QueryManager#refetchQueries.
benjamn May 14, 2021
c2bce76
Move makeUniqueId from QueryManager.ts into @apollo/client/utilities.
benjamn May 14, 2021
512804c
Allow including client.refetchQueries queries by DocumentNode.
benjamn May 18, 2021
491eeaf
Update CHANGELOG.md to reflect changes made in PR #8000.
benjamn May 18, 2021
a5c3308
Merge pull request #8000 from apollographql/client.refetchQueries-revamp
benjamn May 18, 2021
31b66dc
Merge branch 'main' into release-3.4.
benjamn May 18, 2021
0ae1628
Bump @apollo/client npm version to 3.4.0-beta.28.
benjamn May 19, 2021
31e0752
Restrict ObjectCanon prototypes to {Array,Object}.prototype and null.…
benjamn May 18, 2021
9fab4a1
Bump @apollo/client npm version to 3.4.0-rc.0. :tada:
benjamn May 19, 2021
09ac78a
pass along missing field errors to the user
brainkim May 19, 2021
2de299a
update CHANGELOG and package.json
brainkim May 19, 2021
9ec7f17
Remove context.clientOnly tracking from executeSelectionSetImpl.
benjamn Apr 23, 2021
9b6d276
Merge pull request #8262 from apollographql/brian-pass-missing
brainkim May 20, 2021
d716716
Merge branch 'main' into release-3.4
benjamn May 25, 2021
4da232c
Bump @apollo/client npm version to 3.4.0-rc.1.
benjamn May 25, 2021
5dc9db1
Use canonicalStringify instead of JSON.stringify in more places.
benjamn May 24, 2021
f69f250
Use canonicalStringify in deduplicating identical simultaneous queries.
benjamn May 25, 2021
51873d9
Delete ROOT_MUTATION from cache immediately after update.
benjamn May 24, 2021
aeaeedc
Allow field policy read functions to run for mutation result fields.
benjamn Mar 31, 2021
b7ad441
Enforce fetchPolicy:"no-cache" more consistently for mutations.
benjamn May 24, 2021
8a8f1d1
Remove only non-__typename fields from ROOT_MUTATION.
benjamn May 26, 2021
7a3b6b9
Reorganize mutation options types within src/react/types.ts.
benjamn May 26, 2021
6013f2e
Provide an option to keep ROOT_MUTATION fields if necessary.
benjamn May 26, 2021
244e635
Merge pull request #8280 from apollographql/ROOT_MUTATION-caching-adj…
benjamn May 26, 2021
4c6728e
Bump @apollo/client npm version to 3.4.0-rc.2.
benjamn May 26, 2021
b8db49b
Merge branch 'main' into release-3.4.
benjamn May 26, 2021
01573d3
Re-export the MockedResponse ResultFunction type (#8315)
hwillson May 28, 2021
5d5c661
Transform invariant.log(...) expressions (not just .warn and .error).
benjamn May 28, 2021
f76ec87
Consolidate identical isObject functions across codebase.
benjamn Jun 1, 2021
2ae6ddd
Convert a few default imports to named.
benjamn May 28, 2021
e553ed9
Update rollup to latest version, 2.50.5.
benjamn May 27, 2021
d056d47
Fix bug preventing Rollup from inlining relative CJS modules.
benjamn May 27, 2021
1bb182c
Make Rollup inject fewer _interopNamespace helpers.
benjamn May 28, 2021
8c80f1c
Merge pull request #8341 from apollographql/update-rollup-to-v2
benjamn Jun 2, 2021
f12dc3b
Merge branch 'main' into release-3.4.
benjamn Jun 2, 2021
14ffe47
Bump @apollo/client npm version to 3.4.0-rc.3.
benjamn Jun 2, 2021
b8ee3a6
add public method to retrieve all current observable queries
Mar 9, 2021
e673f8b
Use getObservableQueries for refetchQueries include handling.
benjamn Jun 2, 2021
5baa918
Reenable warning about included-but-unused query names/documents.
benjamn Jun 2, 2021
748c90c
Clean up [Internal]RefetchQueriesInclude and related types.
benjamn Jun 2, 2021
4e022bc
Tests of the new "all" and "active" values for options.include.
benjamn Jun 2, 2021
ba92852
Test that both "all" and "active" ignore one-off client.query queries.
benjamn Jun 2, 2021
90b35ef
delete debugger
brainkim Jun 2, 2021
f739214
Add a failing test?
brainkim Jun 3, 2021
5a90c3c
fix polling when skip goes from true to false
brainkim Jun 3, 2021
f6cf7f9
Make "active" exclude cache-only queries only for reFetchObservableQu…
benjamn Jun 4, 2021
1c6314c
Improve legacy refetchQueries test using subscribeAndCount.
benjamn Jun 4, 2021
4a8e265
Clean up legacy one-time queries after refetching in refetchQueries.
benjamn Jun 4, 2021
91c9a1f
Update @wry/equality to version 0.5.0.
benjamn Jun 4, 2021
1e5d4f8
Export reusable applyNextFetchPolicy function from ObservableQuery.ts.
benjamn Jun 4, 2021
ff80d89
Merge pull request #7813 from dannycochran/getObservableQueries
benjamn Jun 4, 2021
1f804a5
Bump @apollo/client npm version to 3.4.0-rc.4.
benjamn Jun 4, 2021
8a78304
Merge pull request #8346 from apollographql/brian-skip-polling-stuff
brainkim Jun 7, 2021
944d2da
Update CHANGELOG.md
brainkim Jun 7, 2021
a711bc2
Merge branch 'main' into release-3.4.
benjamn Jun 7, 2021
2d0ebe7
Bump @apollo/client npm version to 3.4.0-rc.5.
benjamn Jun 7, 2021
9b522cf
Add expected/received variables to 'No more mocked responses' error m…
markneub Jun 7, 2021
e6a6ced
Merge branch 'main' into release-3.4.
benjamn Jun 8, 2021
d3fab0a
Reduce bundlesize limit to 24.3kB, reflecting current size.
benjamn Jun 8, 2021
175321b
Bump @apollo/client npm version to 3.4.0-rc.6.
benjamn Jun 8, 2021
6ffbc8e
Merge all fragment fields before running `merge` functions and updati…
benjamn Jun 14, 2021
764c2f9
Merge branch 'main' into release-3.4.
benjamn Jun 14, 2021
51f2e11
Fix optimistic mutation update test.
benjamn Jun 14, 2021
b9719a6
Use Object.assign for addTypenameToDocument.added.
benjamn Jun 14, 2021
44a1918
Experiment: use __DEV__ instead of process.env.NODE_ENV.
benjamn May 27, 2021
fcb2c7d
Temporarily polyfill global.process while importing graphql package.
benjamn Jun 15, 2021
8f68762
Warn about usage of __DEV__ polyfill.
benjamn Jun 7, 2021
56b1cb5
Increase bundlesize limit from 24.5kB to 24.7kB.
benjamn Jun 15, 2021
28d39cb
Merge pull request #8347 from apollographql/try-__DEV__-instead-of-pr…
benjamn Jun 15, 2021
5de6edb
Bump @apollo/client npm version to 3.4.0-rc.7.
benjamn Jun 15, 2021
f01d48d
Use ts-invariant/process to polyfill global.process temporarily.
benjamn Jun 15, 2021
b24258c
Remove annoying/imperfect warning about __DEV__ minification.
benjamn Jun 16, 2021
54528fa
Bump @apollo/client npm version to 3.4.0-rc.8.
benjamn Jun 16, 2021
57ead4c
Bump ts-invariant to version 0.8.1.
benjamn Jun 16, 2021
75f0a17
Bump @apollo/client npm version to 3.4.0-rc.9.
benjamn Jun 16, 2021
232cf83
Bump ts-invariant to version 0.8.2.
benjamn Jun 16, 2021
51d963f
Export DEV rather than __DEV__ to help find/replace transforms succeed.
benjamn Jun 16, 2021
bfe0e75
Bump @apollo/client npm version to 3.4.0-rc.10.
benjamn Jun 16, 2021
eea2567
Update typescript from v3.9.9 to v4.3.3.
benjamn Jun 17, 2021
a3c6926
Fix type errors after updating typescript.
benjamn Jun 17, 2021
464d5a6
Use exact typescript@4.3.3 version in package.json devDependencies.
benjamn Jun 17, 2021
5a7f65d
Mention consequences of PR #8394 in CHANGELOG.md.
benjamn Jun 17, 2021
608784c
Merge pull request #8394 from apollographql/update-typescript-to-v4.3.3
benjamn Jun 17, 2021
020fa76
Be more defensive against find/replace __DEV__ minifiers.
benjamn Jun 17, 2021
56ecc6a
Advertise sideEffects in @apollo/client/utilities/package.json.
benjamn Jun 17, 2021
e04e959
Actually use DEV import in index.ts files to prevent its tree-shaking.
benjamn Jun 17, 2021
666ed72
Merge pull request #8393 from apollographql/protect-__DEV__-from-mism…
benjamn Jun 17, 2021
72735a3
Bump @apollo/client npm version to 3.4.0-rc.11.
benjamn Jun 17, 2021
188fe51
Merge branch 'main' into release-3.4.
benjamn Jun 22, 2021
d7edb88
Log non-fatal error when fields are missing from written results.
benjamn Jun 14, 2021
d11ea15
New internal testing utility: withErrorSpy(it, "should...", ...)
benjamn Jun 15, 2021
4b4a9b8
Fix tests and capture/check invariant.error messages.
benjamn Jun 14, 2021
1daffc2
Mention PR #8416 in CHANGELOG.md.
benjamn Jun 22, 2021
9efc407
Merge pull request #8416 from apollographql/relax-writeToStore-missin…
benjamn Jun 22, 2021
3a370c6
Bump @apollo/client npm version to 3.4.0-rc.12.
benjamn Jun 22, 2021
4cb88cc
Use WeakSet in ObjectCanon only if available (#8402)
henryqdineen Jun 22, 2021
d76c5a7
inline Reobserver into ObservableQuery
brainkim Jun 10, 2021
56ac597
fix no-cache not working
brainkim Jun 12, 2021
13301df
use a separate concast for refetch
brainkim Jun 15, 2021
a917035
delete fetchPolicy line
brainkim Jun 16, 2021
8b05683
murder Reobserver
brainkim Jun 16, 2021
b98a268
inline shouldFetch
brainkim Jun 16, 2021
1796b49
inline onSubscribe
brainkim Jun 16, 2021
e0e0390
move startQuerySubscription to afterExecute
brainkim Jun 16, 2021
43d6435
delete another usage of startQuerySubscription
brainkim Jun 17, 2021
c32a1ab
Fix react/components/__tests__/client/Query.test.tsx
brainkim Jun 21, 2021
5215a6f
fix hoc test
brainkim Jun 21, 2021
3f8bc8c
add a lil delay to mutations test
brainkim Jun 22, 2021
52141db
add delay to mutation test
brainkim Jun 22, 2021
10cc2da
fix ObservableQuery visibility
brainkim Jun 22, 2021
014078a
update bundlesize
brainkim Jun 22, 2021
a75d31f
add a test for StrictMode polling
brainkim Jun 22, 2021
51b0b05
add test for unmounting in StrictMode
brainkim Jun 22, 2021
8327829
rename getQueryResult to getExecuteResult
brainkim Jun 22, 2021
5d1db15
Update CHANGELOG.md
brainkim Jun 23, 2021
606d6e1
Merge pull request #8414 from apollographql/brian-the-janitor
brainkim Jun 23, 2021
e67711e
Merge branch 'main' into release-3.4.
benjamn Jun 23, 2021
ea0d6b0
Bump @apollo/client npm version to 3.4.0-rc.13.
benjamn Jun 23, 2021
a7e8bf7
Do not forceUpdate if comsuming component is not mounted
wuarmin Feb 22, 2021
446a615
update CHANGELOG.md
brainkim Jun 23, 2021
a164bd8
Merge pull request #7745 from wuarmin/patch-1
brainkim Jun 23, 2021
393fc98
make new type parameters to BaseMutationOptions optional
brainkim Jun 23, 2021
accc147
Merge pull request #8423 from apollographql/brian-typescript-stuff
brainkim Jun 23, 2021
63ad2ef
Bump @apollo/client npm version to 3.4.0-rc.14.
benjamn Jun 23, 2021
04c4ce8
Squash remaining "not wrapped in act(...)" error messages in tests (#…
benjamn Jun 24, 2021
8beabc3
Squash one more act(...) error message.
benjamn Jun 24, 2021
f11a163
Tolerate absolute Windows paths in isExternal Rollup helper.
benjamn Jun 25, 2021
36fea0f
Make `ObservableQuery#getCurrentResult` always call `queryInfo.getDif…
benjamn Jun 28, 2021
fc479e7
Merge branch 'main' into release-3.4.
benjamn Jun 28, 2021
edab367
Bump @apollo/client npm version to 3.4.0-rc.15.
benjamn Jun 28, 2021
622880d
add a failing test for #8274
brainkim Jul 1, 2021
7eae2da
fix unmounting and refetching queries not updating the cache
brainkim Jul 1, 2021
c94c823
add failing tests for refetchQueries with document nodes
brainkim Jul 1, 2021
89e76fb
fix using DocumentNodes in refetchQueries
brainkim Jul 1, 2021
05eb996
Merge pull request #8440 from apollographql/brian-refetch-unmount
brainkim Jul 1, 2021
359860b
Merge branch 'main' into release-3.4.
benjamn Jul 6, 2021
db3439e
Bump bundlesize limit from 24.35kB to 24.4kB.
benjamn Jul 6, 2021
424e4bc
Bump @apollo/client npm version to 3.4.0-rc.16.
benjamn Jul 6, 2021
b8b82c7
Allow specifying canon when creating StoreReader.
benjamn Jun 22, 2021
2d20403
Support cache.gc({ resetResultCache: true }) to jettison result cache.
benjamn Jun 22, 2021
6c7715c
Add options.preserveCanon to cache.gc method.
benjamn Jun 22, 2021
19210de
Call cache.init() in cache.restore to reset EntityStore and result ca…
benjamn Jun 22, 2021
4a85baf
Mention PR #8421 in CHANGELOG.md.
benjamn Jun 23, 2021
8fb9f85
Bump bundlesize limit from 24.4kB to 24.6kB.
benjamn Jun 23, 2021
f0fd5e7
Make StoreReader canon field public.
benjamn Jun 28, 2021
713796a
Align naming of resetResultCache and resetResultIdentities.
benjamn Jun 28, 2021
10d7558
Add FinalizationRegistry test of cache.gc, and make it pass.
benjamn Jun 28, 2021
bb3daf0
Fix comments still mentioning cache.gc({ preserveCanon }).
benjamn Jun 28, 2021
c6dc503
Merge pull request #8421 from apollographql/cache.gc-options.resetRes…
hwillson Jul 6, 2021
3161e31
Bump @apollo/client npm version to 3.4.0-rc.17.
benjamn Jul 6, 2021
337be9e
Inline private QueryInfo#canonize method.
benjamn Jul 6, 2021
b502008
Revert "Make Rollup inject fewer _interopNamespace helpers."
brainkim Jul 7, 2021
99608f9
Merge pull request #8466 from apollographql/brian/studio-dx-fixes
brainkim Jul 8, 2021
4e6c1c2
Update to zen-observable-ts@1.1.0, fixing #8467.
benjamn Jul 9, 2021
add15f5
Avoid deleting options.nextFetchPolicy after applying it.
benjamn Jul 6, 2021
143e2ea
Specify which ObservableQuery operations run independently.
benjamn Jul 6, 2021
231ffbd
Reset options.fetchPolicy in ObservableQuery#setVariables.
benjamn Jul 6, 2021
1ab0161
Improve ObservableQuery nextFetchPolicy test.
benjamn Jul 6, 2021
1dcc2e8
Avoid specifying options.nextFetchPolicy for refetch operations.
benjamn Jul 6, 2021
4bd46ed
Avoid calling applyNextFetchPolicy in prepareObservableQueryOptions.
benjamn Jun 29, 2021
bdac212
Improve type for QueryData["previous"]["observableQueryOptions"].
benjamn Jul 7, 2021
83703c2
Reliably reset fetchPolicy to original value when variables change.
benjamn Jul 7, 2021
5d47432
Test that fetchPolicy is reset when variables change.
benjamn Jul 8, 2021
89126b6
Keep ObservableQuery initialFetchPolicy member private for now.
benjamn Jul 9, 2021
8a98eb9
Mention PR #8465 in CHANGELOG.md, as a "potentially disruptive" change.
benjamn Jul 9, 2021
3e3a2e7
Merge pull request #8465 from apollographql/ObservableQuery-nextFetch…
benjamn Jul 9, 2021
3cfe83c
Bump @apollo/client npm version to 3.4.0-rc.18.
benjamn Jul 9, 2021
e9cf7c1
Suppress `Missing cache result fields...` warnings unless `setLogVerb…
benjamn Jul 12, 2021
64b04aa
Merge branch 'main' into release-3.4.
benjamn Jul 12, 2021
5a33ab9
Bump @apollo/client npm version to 3.4.0-rc.19.
benjamn Jul 12, 2021
8d41184
Bump tslib to latest version, 2.3.0.
benjamn Jul 13, 2021
d83d207
Fix Fast Refresh/Live Reload interaction with React hooks (#7952)
andreialecu Jul 15, 2021
0c0da16
Bump @apollo/client npm version to 3.4.0-rc.20.
benjamn Jul 15, 2021
4a2e38c
Avoid treating { __ref } objects returned by applyMerges as StoreObje…
benjamn Jul 16, 2021
97a1d74
Traverse any other fields of { __ref } objects in findChildRefIds.
benjamn Jul 16, 2021
4832e87
Tolerate surprise Reference arguments in EntityStore#merge.
benjamn Jul 16, 2021
e359e97
Note that mutate/useMutation with @client is not supported in AC3 (#8…
hwillson Jul 16, 2021
6fe0d66
Merge pull request #8505 from apollographql/avoid-mistaking-reference…
benjamn Jul 16, 2021
139b523
Merge branch 'main' into release-3.4.
benjamn Jul 19, 2021
372a690
Bump @apollo/client npm version to 3.4.0-rc.21.
benjamn Jul 19, 2021
92520dd
Default to current object for `readField` only when `from` omitted. (…
benjamn Jul 21, 2021
f02ea7d
Create caching overview and pull content from configuration article (…
Jul 21, 2021
f35c5a8
WIP on updates to mutation article
May 18, 2021
2801529
Update mutation options table
May 18, 2021
381066b
Revisions to mutation-options table
May 18, 2021
2916c5e
Updates to mutation-result
May 18, 2021
6b53f33
Prepare for 3.4 refetch edits
May 19, 2021
dd42182
Fix broken links to #sections within mutations docs.
benjamn May 19, 2021
b1aeb55
Some improvements to the `update` function section.
benjamn May 19, 2021
88cc3a5
Elaborate on "GraphQL string" terminology.
benjamn May 19, 2021
abc05b2
More `code` formatting for `update` functions.
benjamn May 19, 2021
0876f8a
Minor edits in leadup to proper refetch docs
Jun 7, 2021
c71c92a
Section: Refetching queries
benjamn Jun 7, 2021
bdced7c
Use variables as example in useMutation options section.
benjamn Jun 7, 2021
7ef351a
New section: Refetching updated data
benjamn Jun 8, 2021
eafaff8
Add stub onQueryUpdated section to <MutationOptions/>.
benjamn Jul 9, 2021
4d5e410
Basic initial explanation of onQueryUpdated mutation option.
benjamn Jul 13, 2021
40f5b37
Show v3 shared MDX components instead of v2
Jul 13, 2021
3ec5631
Remove broken #TODO link to fix Gatsby preview builds.
benjamn Jul 15, 2021
c5bf852
Minor improvements to mutations article
Jul 19, 2021
6426a72
Add a Refetching docs page under Fetching.
benjamn Jul 19, 2021
770e020
Add a brief explanation of client.refetchQueries results.
benjamn Jul 20, 2021
ed1c9ee
Improve InternalRefetchQueriesResult<TResult> generic type.
benjamn Jul 20, 2021
3a7576c
Partial edits to direct cache updates following mutation
Jul 21, 2021
175c2cb
Fix various broken links.
benjamn Jul 22, 2021
2f04e17
Prevent uncaught rejections of client.refetchQueries result promise.
benjamn Jul 22, 2021
75ef9c4
Clarify deprecation and future plans for local resolvers.
benjamn Jul 22, 2021
f87dbf5
Add "Refetch recipes" section for client.refetchQueries.
benjamn Jul 22, 2021
6d705ae
Show full RefetchQueriesOptions interface type.
benjamn Jul 22, 2021
7164694
Fix link from mutations.mdx to refetching.mdx.
benjamn Jul 22, 2021
be73ce9
Add translation table for client.{mutate,refetchQueries} options.
benjamn Jul 22, 2021
48be27b
Incorporate feedback from @benjamn
Jul 22, 2021
c6542fd
Fix broken link error about #awaitrefetchqueries fragment link.
benjamn Jul 22, 2021
991c1c6
Merge pull request #8265 from apollographql/sb/mutation-edits
Jul 22, 2021
1590859
Bump @apollo/client npm version to 3.4.0-rc.22.
benjamn Jul 22, 2021
9ab9400
Minor adjustments to CHANGELOG.md entry for AC3.4.
benjamn Jul 23, 2021
60db4e4
Move stringifyForDisplay to utilities/common rather than /testing.
benjamn Jul 23, 2021
13331f8
Merge branch 'main' into release-3.4.
benjamn Jul 23, 2021
8147248
Bump @apollo/client npm version to 3.4.0-rc.23.
benjamn Jul 23, 2021
220df30
Reorder CHANGELOG.md sections within AC3.4 heading.
benjamn Jul 23, 2021
3f0c9ef
Mention work to load @apollo/client/core from CDNs in CHANGELOG.md.
benjamn Jul 23, 2021
ced40dd
Merge branch 'main' into release-3.4.
benjamn Jul 26, 2021
a89fc5c
Use 'next' tag rather than 'beta' when publishing @apollo/client to npm.
benjamn Jul 26, 2021
9b532ac
Miscellaneous improvements to caching docs (#8529)
Jul 26, 2021
7b4fdfb
Keep each md paragraph on a single line in refetching article
Jul 26, 2021
55da588
Merge pull request #8545 from apollographql/sb/docs-refetching-mergel…
Jul 26, 2021
7856c18
Style edits to refetching docs (#8547)
Jul 27, 2021
3b2d25b
add optional chaining to obsFetchMore return
noghartt Apr 13, 2021
15762ca
add optional chaining to obsSubscribeToMore return
noghartt Apr 13, 2021
e52764e
add optional chaining to obsUpdateQuery return
brainkim Jul 28, 2021
b677262
Reinstate MutationUpdaterFn for back-compat, with deprecation note.
benjamn Jul 28, 2021
67a0ecb
update CHANGELOG.md
brainkim Jul 28, 2021
64f4569
Merge pull request #8553 from apollographql/optional-chaining-on-useq…
brainkim Jul 28, 2021
550ec23
Bump @apollo/client npm version to 3.4.0 (final). :tada:
benjamn Jul 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
131 changes: 129 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,132 @@
## Apollo Client 3.4.0 (not yet released)

### New documentation

- [**Refetching queries**](https://deploy-preview-7399--apollo-client-docs.netlify.app/docs/react/data/refetching/) with `client.refetchQueries`. <br/>
[@StephenBarlow](https://github.com/StephenBarlow) and [@benjamn](https://github.com/benjamn) in [#8265](https://github.com/apollographql/apollo-client/pull/8265)

### Improvements

- `InMemoryCache` now _guarantees_ that any two result objects returned by the cache (from `readQuery`, `readFragment`, etc.) will be referentially equal (`===`) if they are deeply equal. Previously, `===` equality was often achievable for results for the same query, on a best-effort basis. Now, equivalent result objects will be automatically shared among the result trees of completely different queries. This guarantee is important for taking full advantage of optimistic updates that correctly guess the final data, and for "pure" UI components that can skip re-rendering when their input data are unchanged. <br/>
[@benjamn](https://github.com/benjamn) in [#7439](https://github.com/apollographql/apollo-client/pull/7439)

- Mutations now accept an optional callback function called `onQueryUpdated`, which will be passed the `ObservableQuery` and `Cache.DiffResult` objects for any queries invalidated by cache writes performed by the mutation's final `update` function. Using `onQueryUpdated`, you can override the default `FetchPolicy` of the query, by (for example) calling `ObservableQuery` methods like `refetch` to force a network request. This automatic detection of invalidated queries provides an alternative to manually enumerating queries using the `refetchQueries` mutation option. Also, if you return a `Promise` from `onQueryUpdated`, the mutation will automatically await that `Promise`, rendering the `awaitRefetchQueries` option unnecessary. <br/>
[@benjamn](https://github.com/benjamn) in [#7827](https://github.com/apollographql/apollo-client/pull/7827)

- Support `client.refetchQueries` as an imperative way to refetch queries, without having to pass `options.refetchQueries` to `client.mutate`. <br/>
[@dannycochran](https://github.com/dannycochran) in [#7431](https://github.com/apollographql/apollo-client/pull/7431)

- Improve standalone `client.refetchQueries` method to support automatic detection of queries needing to be refetched. <br/>
[@benjamn](https://github.com/benjamn) in [#8000](https://github.com/apollographql/apollo-client/pull/8000)

- Fix remaining barriers to loading [`@apollo/client/core`](https://cdn.jsdelivr.net/npm/@apollo/client@beta/core/+esm) as native ECMAScript modules from a CDN like [esm.run](https://www.jsdelivr.com/esm). Importing `@apollo/client` from a CDN will become possible once we move all React-related dependencies into `@apollo/client/react` in Apollo Client 4. <br/>
[@benjamn](https://github.com/benjamn) in [#8266](https://github.com/apollographql/apollo-client/issues/8266)

- `InMemoryCache` supports a new method called `batch`, which is similar to `performTransaction` but takes named options rather than positional parameters. One of these named options is an `onDirty(watch, diff)` callback, which can be used to determine which watched queries were invalidated by the `batch` operation. <br/>
[@benjamn](https://github.com/benjamn) in [#7819](https://github.com/apollographql/apollo-client/pull/7819)

- Allow `merge: true` field policy to merge `Reference` objects with non-normalized objects, and vice-versa. <br/>
[@benjamn](https://github.com/benjamn) in [#7778](https://github.com/apollographql/apollo-client/pull/7778)

- Allow identical subscriptions to be deduplicated by default, like queries. <br/>
[@jkossis](https://github.com/jkossis) in [#6910](https://github.com/apollographql/apollo-client/pull/6910)

- Always use `POST` request when falling back to sending full query with `@apollo/client/link/persisted-queries`. <br/>
[@rieset](https://github.com/rieset) in [#7456](https://github.com/apollographql/apollo-client/pull/7456)

- The `FetchMoreQueryOptions` type now takes two instead of three type parameters (`<TVariables, TData>`), thanks to using `Partial<TVariables>` instead of `K extends typeof TVariables` and `Pick<TVariables, K>`. <br/>
[@ArnaudBarre](https://github.com/ArnaudBarre) in [#7476](https://github.com/apollographql/apollo-client/pull/7476)

- Pass `variables` and `context` to a mutation's `update` function. **Note:** The type of the `update` function is now named `MutationUpdaterFunction` rather than `MutationUpdaterFn`, since the older type was [broken beyond repair](https://github.com/apollographql/apollo-client/issues/8506#issuecomment-881706613). If you are using `MutationUpdaterFn` in your own code, please use `MutationUpdaterFunction` instead. <br/>
[@jcreighton](https://github.com/jcreighton) in [#7902](https://github.com/apollographql/apollo-client/pull/7902)

- A `resultCacheMaxSize` option may be passed to the `InMemoryCache` constructor to limit the number of result objects that will be retained in memory (to speed up repeated reads), and calling `cache.reset()` now releases all such memory. <br/>
[@SofianHn](https://github.com/SofianHn) in [#8701](https://github.com/apollographql/apollo-client/pull/8701)

- Fully remove result cache entries from LRU dependency system when the corresponding entities are removed from `InMemoryCache` by eviction, or by any other means. <br/>
[@sofianhn](https://github.com/sofianhn) and [@benjamn](https://github.com/benjamn) in [#8147](https://github.com/apollographql/apollo-client/pull/8147)

- Expose missing field errors in results. <br/>
[@brainkim](github.com/brainkim) in [#8262](https://github.com/apollographql/apollo-client/pull/8262)

- Add expected/received `variables` to `No more mocked responses...` error messages generated by `MockLink`. <br/>
[@markneub](github.com/markneub) in [#8340](https://github.com/apollographql/apollo-client/pull/8340)

- The `InMemoryCache` version of the `cache.gc` method now supports additional options for removing non-essential (recomputable) result caching data. <br/>
[@benjamn](https://github.com/benjamn) in [#8421](https://github.com/apollographql/apollo-client/pull/8421)

- Suppress noisy `Missing cache result fields...` warnings by default unless `setLogVerbosity("debug")` called. <br/>
[@benjamn](https://github.com/benjamn) in [#8489](https://github.com/apollographql/apollo-client/pull/8489)

- Improve interaction between React hooks and React Fast Refresh in development. <br/>
[@andreialecu](https://github.com/andreialecu) in [#7952](https://github.com/apollographql/apollo-client/pull/7952)

### Potentially disruptive changes

- To avoid retaining sensitive information from mutation root field arguments, Apollo Client v3.4 automatically clears any `ROOT_MUTATION` fields from the cache after each mutation finishes. If you need this information to remain in the cache, you can prevent the removal by passing the `keepRootFields: true` option to `client.mutate`. `ROOT_MUTATION` result data are also passed to the mutation `update` function, so we recommend obtaining the results that way, rather than using `keepRootFields: true`, if possible. <br/>
[@benjamn](https://github.com/benjamn) in [#8280](https://github.com/apollographql/apollo-client/pull/8280)

- Internally, Apollo Client now controls the execution of development-only code using the `__DEV__` global variable, rather than `process.env.NODE_ENV`. While this change should not cause any visible differences in behavior, it will increase your minified+gzip bundle size by more than 3.5kB, unless you configure your minifier to replace `__DEV__` with a `true` or `false` constant, the same way you already replace `process.env.NODE_ENV` with a string literal like `"development"` or `"production"`. For an example of configuring a Create React App project without ejecting, see this pull request for our [React Apollo reproduction template](https://github.com/apollographql/react-apollo-error-template/pull/51). <br/>
[@benjamn](https://github.com/benjamn) in [#8347](https://github.com/apollographql/apollo-client/pull/8347)

- Internally, Apollo Client now uses namespace syntax (e.g. `import * as React from "react"`) for imports whose types are re-exported (and thus may appear in `.d.ts` files). This change should remove any need to configure `esModuleInterop` or `allowSyntheticDefaultImports` in `tsconfig.json`, but might require updating bundler configurations that specify named exports of the `react` and `prop-types` packages, to include exports like `createContext` and `createElement` ([example](https://github.com/apollographql/apollo-client/commit/16b08e1af9ba9934041298496e167aafb128c15d)). <br/>
[@devrelm](https://github.com/devrelm) in [#7742](https://github.com/apollographql/apollo-client/pull/7742)

- Respect `no-cache` fetch policy (by not reading any `data` from the cache) for `loading: true` results triggered by `notifyOnNetworkStatusChange: true`. <br />
[@jcreighton](https://github.com/jcreighton) in [#7761](https://github.com/apollographql/apollo-client/pull/7761)

- The TypeScript return types of the `getLastResult` and `getLastError` methods of `ObservableQuery` now correctly include the possibility of returning `undefined`. If you happen to be calling either of these methods directly, you may need to adjust how the calling code handles the methods' possibly-`undefined` results. <br/>
[@benjamn](https://github.com/benjamn) in [#8394](https://github.com/apollographql/apollo-client/pull/8394)

- Log non-fatal `invariant.error` message when fields are missing from result objects written into `InMemoryCache`, rather than throwing an exception. While this change relaxes an exception to be merely an error message, which is usually a backwards-compatible change, the error messages are logged in more cases now than the exception was previously thrown, and those new error messages may be worth investigating to discover potential problems in your application. The errors are not displayed for `@client`-only fields, so adding `@client` is one way to handle/hide the errors for local-only fields. Another general strategy is to use a more precise query to write specific subsets of data into the cache, rather than reusing a larger query that contains fields not present in the written `data`. <br/>
[@benjamn](https://github.com/benjamn) in [#8416](https://github.com/apollographql/apollo-client/pull/8416)

- The [`nextFetchPolicy`](https://github.com/apollographql/apollo-client/pull/6893) option for `client.watchQuery` and `useQuery` will no longer be removed from the `options` object after it has been applied, and instead will continue to be applied any time `options.fetchPolicy` is reset to another value, until/unless the `options.nextFetchPolicy` property is removed from `options`. <br/>
[@benjamn](https://github.com/benjamn) in [#8465](https://github.com/apollographql/apollo-client/pull/8465)

- The `fetchMore`, `subscribeToMore`, and `updateQuery` functions returned from the `useQuery` hook may now return undefined in edge cases where the functions are called when the component is unmounted <br/> [@noghartt](https://github.com/noghartt) in [#7980](https://github.com/apollographql/apollo-client/pull/7980).

### Bug fixes

- In Apollo Client 2.x, a `refetch` operation would always replace existing data in the cache. With the introduction of field policy `merge` functions in Apollo Client 3, existing field values could be inappropriately combined with incoming field values by a custom `merge` function that does not realize a `refetch` has happened.

To give you more control over this behavior, we have introduced an `overwrite?: boolean = false` option for `cache.writeQuery` and `cache.writeFragment`, and an option called `refetchWritePolicy?: "merge" | "overwrite"` for `client.watchQuery`, `useQuery`, and other functions that accept `WatchQueryOptions`. You can use these options to make sure any `merge` functions involved in cache writes for `refetch` operations get invoked with `undefined` as their first argument, which simulates the absence of any existing data, while still giving the `merge` function a chance to determine the internal representation of the incoming data.

The default behaviors are `overwrite: true` and `refetchWritePolicy: "overwrite"`, which restores the Apollo Client 2.x behavior, but (if this change causes any problems for your application) you can easily recover the previous merging behavior by setting a default value for `refetchWritePolicy` in `defaultOptions.watchQuery`:
```ts
new ApolloClient({
defaultOptions: {
watchQuery: {
refetchWritePolicy: "merge",
},
},
})
```
[@benjamn](https://github.com/benjamn) in [#7810](https://github.com/apollographql/apollo-client/pull/7810)

- Make sure the `MockedResponse` `ResultFunction` type is re-exported. <br/>
[@hwillson](https://github.com/hwillson) in [#8315](https://github.com/apollographql/apollo-client/pull/8315)

- Fix polling when used with `skip`. <br/>
[@brainkim](https://github.com/brainkim) in [#8346](https://github.com/apollographql/apollo-client/pull/8346)

- `InMemoryCache` now coalesces `EntityStore` updates to guarantee only one `store.merge(id, fields)` call per `id` per cache write. <br/>
[@benjamn](https://github.com/benjamn) in [#8372](https://github.com/apollographql/apollo-client/pull/8372)

- Fix polling when used with `<React.StrictMode>`. <br/>
[@brainkim](https://github.com/brainkim) in [#8414](https://github.com/apollographql/apollo-client/pull/8414)

- Fix the React integration logging `Warning: Can't perform a React state update on an unmounted component`. <br/>
[@wuarmin](https://github.com/wuarmin) in [#7745](https://github.com/apollographql/apollo-client/pull/7745)

- Make `ObservableQuery#getCurrentResult` always call `queryInfo.getDiff()`. <br/>
[@benjamn](https://github.com/benjamn) in [#8422](https://github.com/apollographql/apollo-client/pull/8422)

- Make `readField` default to reading from current object only when the `from` option/argument is actually omitted, not when `from` is passed to `readField` with an undefined value. A warning will be printed when this situation occurs. <br/>
[@benjamn](https://github.com/benjamn) in [#8508](https://github.com/apollographql/apollo-client/pull/8508)

- The `fetchMore`, `subscribeToMore`, and `updateQuery` functions no longer throw `undefined` errors <br/> [@noghartt](https://github.com/noghartt) in [#7980](https://github.com/apollographql/apollo-client/pull/7980).

## Apollo Client 3.3.21

### Bug fixes
Expand Down Expand Up @@ -61,8 +190,6 @@

## Apollo Client 3.3.15

### Bug fixes

- Increment `queryInfo.lastRequestId` only when making a network request through the `ApolloLink` chain, rather than every time `fetchQueryByPolicy` is called. <br/>
[@dannycochran](https://github.com/dannycochran) in [#7956](https://github.com/apollographql/apollo-client/pull/7956)

Expand Down
5 changes: 4 additions & 1 deletion config/entryPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const entryPoints = [
{ dirs: ['react', 'hooks'] },
{ dirs: ['react', 'parser'] },
{ dirs: ['react', 'ssr'] },
{ dirs: ['utilities'] },
{ dirs: ['utilities'],
sideEffects: [
"./globals/**"
]},
{ dirs: ['testing'], extensions: [".js", ".jsx"] },
];

Expand Down
2 changes: 1 addition & 1 deletion config/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function eachFile(dir: string, callback: (
) => any) {
const promises: Promise<any>[] = [];

return new Promise((resolve, reject) => {
return new Promise<void>((resolve, reject) => {
glob(`${dir}/**/*.js`, (error, files) => {
if (error) return reject(error);

Expand Down
3 changes: 2 additions & 1 deletion config/prepareDist.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fs.copyFileSync(`${srcDir}/LICENSE`, `${destDir}/LICENSE`);
entryPoints.forEach(function buildPackageJson({
dirs,
bundleName = dirs[dirs.length - 1],
sideEffects = false,
}) {
if (!dirs.length) return;
fs.writeFileSync(
Expand All @@ -71,7 +72,7 @@ entryPoints.forEach(function buildPackageJson({
main: `${bundleName}.cjs.js`,
module: 'index.js',
types: 'index.d.ts',
sideEffects: false,
sideEffects,
}, null, 2) + "\n",
);
});
47 changes: 18 additions & 29 deletions config/processInvariants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,50 +71,50 @@ function transform(code: string, file: string) {
const node = path.node;

if (isCallWithLength(node, "invariant", 1)) {
if (isNodeEnvConditional(path.parent.node)) {
if (isDEVConditional(path.parent.node)) {
return;
}

const newArgs = node.arguments.slice(0, 1);
newArgs.push(getErrorCode(file, node));

return b.conditionalExpression(
makeNodeEnvTest(),
makeDEVExpr(),
node,
b.callExpression.from({
...node,
arguments: newArgs,
}),
node,
);
}

if (node.callee.type === "MemberExpression" &&
isIdWithName(node.callee.object, "invariant") &&
isIdWithName(node.callee.property, "warn", "error")) {
if (isNodeEnvLogicalOr(path.parent.node)) {
isIdWithName(node.callee.property, "debug", "log", "warn", "error")) {
if (isDEVLogicalAnd(path.parent.node)) {
return;
}
return b.logicalExpression("||", makeNodeEnvTest(), node);
return b.logicalExpression("&&", makeDEVExpr(), node);
}
},

visitNewExpression(path) {
this.traverse(path);
const node = path.node;
if (isCallWithLength(node, "InvariantError", 0)) {
if (isNodeEnvConditional(path.parent.node)) {
if (isDEVConditional(path.parent.node)) {
return;
}

const newArgs = [getErrorCode(file, node)];

return b.conditionalExpression(
makeNodeEnvTest(),
makeDEVExpr(),
node,
b.newExpression.from({
...node,
arguments: newArgs,
}),
node,
);
}
}
Expand All @@ -137,32 +137,21 @@ function isCallWithLength(
node.arguments.length > length;
}

function isNodeEnvConditional(node: Node) {
function isDEVConditional(node: Node) {
return n.ConditionalExpression.check(node) &&
isNodeEnvExpr(node.test);
isDEVExpr(node.test);
}

function isNodeEnvLogicalOr(node: Node) {
function isDEVLogicalAnd(node: Node) {
return n.LogicalExpression.check(node) &&
node.operator === "||" &&
isNodeEnvExpr(node.left);
node.operator === "&&" &&
isDEVExpr(node.left);
}

function makeNodeEnvTest() {
return b.binaryExpression(
"===",
b.memberExpression(
b.memberExpression(
b.identifier("process"),
b.identifier("env")
),
b.identifier("NODE_ENV"),
),
b.stringLiteral("production"),
);
function makeDEVExpr() {
return b.identifier("__DEV__");
}

const referenceNodeEnvExpr = makeNodeEnvTest();
function isNodeEnvExpr(node: Node) {
return recast.types.astNodesAreEquivalent(node, referenceNodeEnvExpr);
function isDEVExpr(node: Node) {
return isIdWithName(node, "__DEV__");
}