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.5.0 #8554

Merged
merged 227 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
227 commits
Select commit Hold shift + click to select a range
ee59d82
Add `"type": "module"` to `@apollo/client/core`
bennypowers Jun 18, 2021
a597eff
use `"type": "module"` for all packages
bennypowers Jun 18, 2021
f5a7a58
Use just .cjs for CommonJS bundles, rather than .cjs.js.
benjamn Jun 23, 2021
60e18e9
Make resolveModuleIds.ts resolve bare/non-relative package imports, too.
benjamn Jun 23, 2021
57c451f
Merge pull request #8396 from bennypowers/patch-1
benjamn Jul 28, 2021
4544a6b
Add --tag beta to npm publish command for release-3.5.
benjamn Jul 28, 2021
83ed1fc
Bump @apollo/client npm version to 3.5.0-beta.0.
benjamn Jul 28, 2021
3955869
Update to "lockfileVersion":2 for npm v7 in package-lock.json.
benjamn Jul 28, 2021
d07839e
Delay initializing stringifyCanon until canonicalStringify used.
benjamn Jul 29, 2021
ff01c16
Mention PR #8557 in CHANGELOG.md.
benjamn Jul 29, 2021
0ac9790
Merge branch 'lazy-stringifyCanon-initialization' into release-3.5.
benjamn Jul 29, 2021
7ca8d30
Bump @apollo/client npm version to 3.5.0-beta.1.
benjamn Jul 29, 2021
0377d22
Merge branch 'main' into release-3.5.
benjamn Jul 29, 2021
1f29871
Add "type":"module" to published root package.json file.
benjamn Jul 30, 2021
962ec16
Merge branch 'main' into release-3.5.
benjamn Aug 2, 2021
db42372
Bump @apollo/client npm version to 3.5.0-beta.2.
benjamn Aug 2, 2021
0a40cab
Merge branch 'main' into release-3.5.
benjamn Aug 3, 2021
68ec752
Bump @apollo/client npm version to 3.5.0-beta.3.
benjamn Aug 3, 2021
c9fc8b7
Merge branch 'main' into release-3.5.
benjamn Aug 4, 2021
a7fefda
Bump @apollo/client npm version to 3.5.0-beta.4.
benjamn Aug 4, 2021
47269c9
Merge branch 'main' into release-3.5.
benjamn Aug 9, 2021
91dcdb5
Generate bundlesize artifacts into .gitignore'd temp/ directory.
benjamn Aug 9, 2021
3fa6ab9
Bump @apollo/client npm version to 3.5.0-beta.5.
benjamn Aug 9, 2021
92a7bed
Merge branch 'main' into release-3.5.
benjamn Aug 16, 2021
a54bcb2
copy some tests from Query
brainkim Aug 5, 2021
eb972f1
refactor the partial refetch tests
brainkim Aug 5, 2021
daee4e9
more assertions in the partialRefetch stuff
brainkim Aug 6, 2021
de27ddc
add another test with partialRefetch
brainkim Aug 6, 2021
faad4fb
add a testTimeout to debug command
brainkim Aug 9, 2021
d6e7442
update useLazyQuery tests to use react testing hooks library
brainkim Aug 10, 2021
f19855f
fix some timings in useLazyQuery
brainkim Aug 11, 2021
b6445f9
Inline everything into useQuery
brainkim Jul 23, 2021
599cd40
Stop delaying useQuery calls by a microtask
brainkim Jul 23, 2021
ba37f54
fix missing paren
brainkim Jul 26, 2021
b765499
delete some unnecessary things
brainkim Jul 26, 2021
04209ff
don’t have a separate previousOptions property
brainkim Jul 26, 2021
9a67046
add an explicit return type to RenderPromises.getSSRObservable
brainkim Jul 27, 2021
2bd2d2b
crack some eggs
brainkim Jul 27, 2021
9bc6a64
inline getExecuteSsrResult
brainkim Jul 27, 2021
6be18a1
inline getExecuteResult
brainkim Jul 28, 2021
f736f16
Create a temporary useQuery1 hook
brainkim Aug 2, 2021
76dcd52
initial refactor of useQuery1
brainkim Aug 2, 2021
5526f93
Fix ssr: false test
brainkim Aug 2, 2021
888789f
add skip to the new useQuery1
brainkim Aug 3, 2021
2e75c0b
Bring partialData logic to the new useQuery1 hook
brainkim Aug 3, 2021
98e84e1
handle errors with the new useQuery1 hook
brainkim Aug 3, 2021
18197c8
do the dang void 0 stuff
brainkim Aug 3, 2021
8fa0766
fix skip test
brainkim Aug 3, 2021
2730e24
implement ssr in the new useQuery1 hook
brainkim Aug 3, 2021
4fcb5e3
delete useQuery1
brainkim Aug 5, 2021
baf31cd
fix previousResult not updating on error
brainkim Aug 5, 2021
e1c197c
remove an unnecessary setResult call in partialRefetch effect
brainkim Aug 6, 2021
fbd4e62
bring back the old errors to error behavior in useQuery
brainkim Aug 6, 2021
a5dd403
reset the result when the client changes
brainkim Aug 9, 2021
5046395
update some test timings
brainkim Aug 6, 2021
d5bd6e8
do partialRefetch directly in the render execution
brainkim Aug 10, 2021
8d0c814
update partialRefetch tests
brainkim Aug 10, 2021
24f3cab
move result.errors -> error stuff into its own code branch
brainkim Aug 10, 2021
c6691f6
implement useLazyQuery in terms of useQuery
brainkim Aug 11, 2021
fc12809
move verifyDocumentType utility to parser
brainkim Aug 11, 2021
d5754f4
smoooooosh useMutation into a single file
brainkim Aug 11, 2021
7365598
refactor useMutation to not use MutationData
brainkim Aug 11, 2021
8263a1e
refactor useSubscription to not use SubscriptionData
brainkim Aug 12, 2021
8c39483
update useSubscription tests
brainkim Aug 12, 2021
96cda70
Delete OperationData, QueryData, MutationData, SubscriptionData, useB…
brainkim Aug 12, 2021
0b54af7
reuse useApolloClient in the other hooks
brainkim Aug 12, 2021
5e75f24
remove resetQueryStoreErrors call from useQuery
brainkim Aug 12, 2021
fb87263
add a comment about some useSubscription weirdness
brainkim Aug 12, 2021
92a262f
fix useMutation test flake
brainkim Aug 13, 2021
91945a1
clean up useQuery
brainkim Aug 13, 2021
0eb8888
clean up hooks
brainkim Aug 13, 2021
726424f
Allow observableQuery methods to be called by useLazyQuery
brainkim Aug 13, 2021
b9808e2
treat standby fetch policies like skip queries
brainkim Aug 13, 2021
fc16541
call setOptions based on watchQueryOptions
brainkim Aug 13, 2021
9e523d5
add a test to make sure pollInterval triggers onCompleted
brainkim Aug 13, 2021
14cf342
Don’t refetch when fetchPolicy is standby
brainkim Aug 13, 2021
977d83d
fix useLazyQuery not refetching with the correct variables when execu…
brainkim Aug 13, 2021
91fbb4f
use the ref to reference callbacks in useSubscription
brainkim Aug 16, 2021
69a08ae
standardize naming across useMutation and useLazyQuery
brainkim Aug 16, 2021
29048b3
clarify refetch fetchPolicy code
brainkim Aug 16, 2021
d33132e
explicitly specify which methods should execute a useLazyQuery method
brainkim Aug 16, 2021
7712bfa
use itAsync
brainkim Aug 16, 2021
f1a9770
prioritize result.error calling onError over result.data calling onCo…
brainkim Aug 16, 2021
1933ff1
add some delay to possibly fix some flake in a useLazyQuery test
brainkim Aug 16, 2021
c6d41e2
rename data to previousData in useQuery
brainkim Aug 18, 2021
1834f5f
add a busted cache-and-network test
brainkim Aug 18, 2021
73569ef
add a test for #8497
brainkim Aug 18, 2021
7b95b24
tweak useMutation
brainkim Aug 18, 2021
f3e1f35
update CHANGELOG.md
brainkim Aug 18, 2021
a4dfee5
Merge pull request #8596 from apollographql/brian-murder-querydata
brainkim Aug 18, 2021
0cb6e25
Bump @apollo/client npm version to 3.5.0-beta.6.
benjamn Aug 18, 2021
ffbddbf
Adjust formatting of v3.5.0 entry in CHANGELOG.md.
benjamn Aug 18, 2021
7b6fc1a
Merge branch 'issue-8674-enforce-__DEV__-everywhere' into release-3.5.
benjamn Aug 23, 2021
0ff3de1
Bump @apollo/client npm version to 3.5.0-beta.7.
benjamn Aug 23, 2021
ed9f5cb
Update `zen-observable-ts` to eliminate transitive dependency on `@ty…
benjamn Aug 24, 2021
02405fc
Merge branch 'main' into release-3.5.
benjamn Aug 24, 2021
82c71dc
Add `updateQuery` and `updateFragment` methods to `ApolloCache` (#8382)
wassim-k Aug 24, 2021
698bb87
Bump @apollo/client npm version to 3.5.0-beta.8.
benjamn Aug 24, 2021
ba34730
Support field `key` policy as a more general synonym for `keyArgs`.
benjamn Aug 19, 2021
77893c8
Test that key and keyArgs field policies are synonymous.
benjamn Aug 19, 2021
55cf401
Test `key: ["@directive"]` field policies.
benjamn Aug 19, 2021
097abae
Test `key: ["$variable"]` field policies.
benjamn Aug 20, 2021
0c4c008
Bump bundlesize limit to 24.9kB (now 24.88kB).
benjamn Aug 20, 2021
9e37036
Also export FieldKeyFunction type using older name KeyArgsFunction.
benjamn Aug 25, 2021
573a8ea
Improve pagination documentation about the @connection directive.
benjamn Aug 25, 2021
5362b19
Mention PR #8678 in CHANGELOG.md.
benjamn Aug 25, 2021
f0cea05
Remove `key` synonym for `keyArgs`, as it only increases confusion.
benjamn Aug 25, 2021
0f6e613
Merge pull request #8678 from apollographql/allow-directives-and-vari…
benjamn Aug 25, 2021
2710481
Improve `keyFields` error behavior when primary key fields are missin…
benjamn Aug 26, 2021
030bef9
Merge branch 'main' into release-3.5.
benjamn Aug 26, 2021
c168f2a
Bump @apollo/client npm version to 3.5.0-beta.9.
benjamn Aug 26, 2021
2a5e62c
Bump bundlesize limit to 24.95kB (now 24.9kB).
benjamn Aug 26, 2021
52f1e79
Suppress `StoreWriter` errors for missing fields with `read` function…
benjamn Aug 27, 2021
91ae6ee
Use Transformer class for config/resolveModuleIds.ts.
benjamn Aug 30, 2021
082894d
Merge branch 'main' into release-3.5.
benjamn Aug 30, 2021
4a0e8dd
Subscribe even if client.disableNetworkFetches true in useQuery.
benjamn Aug 30, 2021
556be5c
Avoid returning stale cache data for fetch policies like network-only.
benjamn Aug 30, 2021
b640025
Bump @apollo/client npm version to 3.5.0-beta.10.
benjamn Aug 30, 2021
f6e3520
Add basic implementation
sarahghp Aug 24, 2021
7b3cb3d
Adapt existing tests and function calls
sarahghp Aug 25, 2021
7139cb5
Update bundlesize
sarahghp Aug 26, 2021
aa468f7
Add specs for custom printer
sarahghp Aug 30, 2021
0200cb9
Add documention for new option
sarahghp Aug 30, 2021
10ad2f7
Tweaks for `HttpLink` docs about custom `print` functions
benjamn Aug 30, 2021
93f891e
Mention PR #8699 in CHANGELOG.md.
benjamn Aug 30, 2021
02f0083
Merge pull request #8699 from sarahghp/remove-query-whitespace-take-ii
benjamn Aug 30, 2021
9daa8fa
Bump @apollo/client npm version to 3.5.0-beta.11.
benjamn Aug 30, 2021
b61e885
Move `queryInfo.getDiff()` back inside conditional block.
benjamn Aug 30, 2021
fe585d3
Merge branch 'main' into release-3.5.
benjamn Sep 10, 2021
bbffdb8
Bump @apollo/client npm version to 3.5.0-beta.12.
benjamn Sep 10, 2021
0d7fc64
Make `@apollo/client/testing` a proper independent entry point (#8769)
benjamn Sep 13, 2021
d18f800
Added testing/core entry point
Aug 22, 2021
3686df2
Split testing/mocking into testing/core/mocking and testing/react.
benjamn Sep 10, 2021
e3f5ed9
Mention PR #8687 in CHANGELOG.md.
benjamn Sep 10, 2021
c929c0d
Merge pull request #8687 from wassim-k/feature/testing-core-entry-point
benjamn Sep 13, 2021
080d628
Merge branch 'main' into release-3.5.
benjamn Sep 13, 2021
97ae54f
Bump @apollo/client npm version to 3.5.0-beta.13.
benjamn Sep 13, 2021
f33b6b0
Measure bundlesize using `@apollo/client` root package again.
benjamn Sep 13, 2021
553d984
Restore TVariables to useQuery return type
keithlayne Sep 17, 2021
4bb0349
Merge pull request #8801 from keithlayne/3.5-useQuery-return-type
brainkim Sep 17, 2021
d9e59a5
Merge branch 'main' into release-3.5.
benjamn Sep 17, 2021
51954c4
Bump @apollo/client npm version to 3.5.0-beta.14.
benjamn Sep 17, 2021
756ab87
Report single `MissingFieldError` for incomplete cache reads (#8734)
benjamn Sep 17, 2021
78d0d78
Make `cache.batch` return the result of calling `options.update`.
benjamn Aug 24, 2021
8dd371b
Use `cache.batch` in `cache.update{Query,Fragment}`.
benjamn Aug 26, 2021
0a6dfa5
Mention PR #8696 in CHANGELOG.md.
benjamn Aug 24, 2021
bb1bda1
Improve generic type inference for cache.watch.
benjamn Aug 26, 2021
cfb2d88
Test that `cache.update{Query,Fragment}` are broadcast-batched.
benjamn Aug 26, 2021
6bf12cb
Use more descriptive type parameter names for cache.batch.
benjamn Sep 17, 2021
8ff2f49
Merge pull request #8696 from apollographql/make-cache.batch-return-o…
benjamn Sep 17, 2021
2a8f136
Bump @apollo/client npm version to 3.5.0-beta.15.
benjamn Sep 17, 2021
afaad2c
Remove stray `debugger` statement from `StoreWriter` tests.
benjamn Sep 17, 2021
a44dece
Merge branch 'main' into release-3.5.
benjamn Sep 20, 2021
34b41a0
Bump @apollo/client npm version to 3.5.0-beta.16.
benjamn Sep 20, 2021
6ec967d
Merge branch 'main' into release-3.5.
benjamn Sep 27, 2021
7c4cd73
Avoid mutating independently-frozen result objects in DeepMerger.
benjamn Sep 27, 2021
152483d
Bump bundlesize limit to 27.85kB (now 27.81kB).
benjamn Sep 27, 2021
923d670
Bump @apollo/client npm version to 3.5.0-beta.17.
benjamn Sep 27, 2021
1f2ced4
align NetworkError and GraphQLErrors types
korywka Jun 24, 2021
27f2f80
Merge pull request #8424 from korywka/align-error-types
brainkim Sep 28, 2021
a632e45
Make useLazyQuery execution function return a promise
brainkim Sep 30, 2021
68e7df2
Allow mutations to be reset
brainkim Sep 30, 2021
ddaa5df
bump bundlesize yet again
brainkim Sep 30, 2021
4bf41c2
Update CHANGELOG.md
brainkim Oct 1, 2021
c2b0f91
Merge pull request #8875 from apollographql/brian-react-quality-of-life
brainkim Oct 1, 2021
70d6953
Merge branch 'main' into release-3.5.
benjamn Oct 1, 2021
b15c731
Bump @apollo/client npm version to 3.5.0-beta.18.
benjamn Oct 1, 2021
94cd78c
Document changes in #8875 (#8878)
brainkim Oct 4, 2021
7648295
document updateQuery/updateFragment (#8867)
brainkim Oct 4, 2021
a454984
Bump @apollo/client npm version to 3.5.0-rc.0. :tada:
benjamn Oct 4, 2021
3968b41
Edits for updateQuery/updateFragment docs
Sep 30, 2021
b42d65a
Merge pull request #8892 from apollographql/sb/docs-updatequery
Oct 4, 2021
038ea29
Merge branch 'main' into release-3.5.
benjamn Oct 4, 2021
484b7b4
Bump @apollo/client npm version to 3.5.0-rc.1.
benjamn Oct 4, 2021
9cfe989
Improve error/warning detection in writeToStore.ts tests.
benjamn Oct 18, 2021
76266a1
Flatten selection set fields before processing them.
benjamn Oct 14, 2021
f8ccf8d
Generalize `@client` directive support to handle `@defer` too.
benjamn Oct 18, 2021
ac84361
Take full advantage of flattenFields returning only FieldNodes.
benjamn Oct 18, 2021
d88fdf2
Rename incomingFields variable to avoid confusion with fieldNodeSet.
benjamn Oct 18, 2021
90a1c40
Refactor writeToStore `@client` tests to make testing `@defer` easy.
benjamn Oct 20, 2021
aaeabb9
Test flattenFields with `@defer` (without `@client`).
benjamn Oct 20, 2021
7dc9e2e
Add tests of flattenFields mixing `@client` and `@defer` directives.
benjamn Oct 20, 2021
990f61b
Inline include and matchFragment callbacks into flattenFields.
benjamn Oct 21, 2021
065d33c
Pass WriteContext recursively through flatten function.
benjamn Oct 21, 2021
b8872b4
Respect `@defer(if: boolean)` argument in flattenFields.
benjamn Oct 21, 2021
be3e44c
Make flattenFields context type generic.
benjamn Oct 22, 2021
494b66c
Reset context.{clientOnly,deferred} for nested selection sets.
benjamn Oct 22, 2021
2b65237
Ensure `@defer(if: false)` leaves `context.deferred` unchanged.
benjamn Oct 22, 2021
8f5708a
Bump bundlesize limit to 28.25kB (now 28.23kB).
benjamn Oct 18, 2021
5d85f65
Merge pull request #8951 from apollographql/client-directive-on-fragm…
benjamn Oct 22, 2021
fe4b56f
Merge branch 'main' into release-3.5.
benjamn Oct 22, 2021
05dcf21
Add back whatwg-fetch test dependency, removed in PR #8954.
benjamn Oct 22, 2021
d9cc3d6
Bump @apollo/client npm version to 3.5.0-rc.2.
benjamn Oct 22, 2021
e76f49b
allow npm 8 to be used (#8970)
brainkim Oct 25, 2021
8ace4b7
Adding an `onQueryUpdated` callback to a mutation should not prevent …
benjamn Oct 28, 2021
16b2d51
Merge branch 'main' into release-3.5.
benjamn Oct 28, 2021
5d01289
Decompose and export makeReadFieldFunction.
benjamn Oct 19, 2021
d3c5280
Use readField wrapper function in processSelectionSet.
benjamn Oct 25, 2021
4c5cb3d
Move policies.identify after field traversal in processSelectionSet.
benjamn Oct 22, 2021
043df16
Make policies.identify take a KeyFieldsContext.
benjamn Oct 22, 2021
fd33a40
Simplify keyFields extraction by removing AliasMap logic.
benjamn Oct 22, 2021
b5c6fab
Test that nested keyFields objects are stably stringified.
benjamn Sep 28, 2021
b880fcc
Export normalizeReadFieldOptions rather than makeReadFieldFunction.
benjamn Oct 25, 2021
f25b3d2
Assemble complete KeyFieldsContext from partial policies.identify input.
benjamn Oct 25, 2021
634e21b
Tolerate policies.identify failure when dataId already provided.
benjamn Oct 27, 2021
39d4f0f
Rely on existence of context.readField in keyFieldsFnFromSpecifier.
benjamn Nov 1, 2021
40fbe62
Hoist normalize function out of extractKeyPath.
benjamn Nov 3, 2021
1d01a67
Slightly better return type for collectSpecifierPaths.
benjamn Nov 3, 2021
ed125f3
Move array logic into extractKeyPath reducer to simplify extractKey.
benjamn Nov 3, 2021
cd99118
Cache immutable KeySpecifier-derived information to improve performance.
benjamn Nov 3, 2021
280ab72
Bump bundlesize limit to 28.45kB (now 28.44kB).
benjamn Nov 1, 2021
ce170ed
Mention PR #8996 in CHANGELOG.md.
benjamn Nov 3, 2021
b3a2461
Merge pull request #8996 from apollographql/identify-written-results-…
benjamn Nov 3, 2021
d403a07
Merge branch 'main' into release-3.5.
benjamn Nov 3, 2021
82baff2
Bump @apollo/client npm version to 3.5.0-rc.3.
benjamn Nov 3, 2021
278ba5f
Update jest-related dependencies to fix npm audit vulnerabilities.
benjamn Nov 3, 2021
7457128
Fix tests after updating Jest.
benjamn Nov 3, 2021
9de5c61
Remove remaining `done()`-style tests from codebase.
benjamn Nov 4, 2021
f03a47a
Merge pull request #9004 from apollographql/update-jest-dependencies-…
benjamn Nov 4, 2021
9b7c0a6
Update typedoc to fix "Maximum call stack size exceeded" errors
hwillson Nov 5, 2021
97bda17
Adjust netlify config to make sure AC + docs are installed/built
hwillson Nov 6, 2021
6b8d13d
Bump to the latest gatsby-theme-apollo-docs version
hwillson Nov 8, 2021
24799a9
Upgrade to graphql 16
brainkim Nov 8, 2021
f7c0696
Merge branch 'main' into release-3.5
hwillson Nov 8, 2021
cc5d86a
Remove the publish beta tag
hwillson Nov 8, 2021
5227096
Changelog update; prep for publish
hwillson Nov 8, 2021
e2d86b6
Merge branch 'main' into release-3.5
hwillson Nov 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ dist
npm
!flow-typed/npm

# Unpublished output from @apollo/client build, like bundlesize artifacts
temp/

# webstorm
.idea/

Expand Down
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,73 @@
## Apollo Client 3.5.0 (2021-11-08)

### Improvements

- Add `updateQuery` and `updateFragment` methods to `ApolloCache`, simplifying common `readQuery`/`writeQuery` cache update patterns. <br/>
[@wassim-k](https://github.com/wassim-k) in [#8382](https://github.com/apollographql/apollo-client/pull/8382)

- Field directives and their arguments can now be included along with field argument names when using [field policy `keyArgs: [...]` notation](https://www.apollographql.com/docs/react/pagination/key-args/). For example, if you have a `Query.feed` field that takes an argument called `type` and uses a `@connection(key:...)` directive to keep `feed` data from different queries separate within the cache, you might configure both using the following `InMemoryCache` field policy:
```ts
new InMemoryCache({
typePolicies: {
Query: {
fields: {
feed: {
keyArgs: ["type", "@connection", ["key"]],
},
},
},
},
})
```
[@benjamn](https://github.com/benjamn) in [#8678](https://github.com/apollographql/apollo-client/pull/8678)

- Report single `MissingFieldError` instead of a potentially very large `MissingFieldError[]` array for incomplete cache reads, improving performance and memory usage. <br/>
[@benjamn](https://github.com/benjamn) in [#8734](https://github.com/apollographql/apollo-client/pull/8734)

- When writing results into `InMemoryCache`, each written object is now identified using `policies.identify` _after_ traversing the fields of the object (rather than before), simplifying identification and reducing duplicate work. If you have custom `keyFields` functions, they still receive the raw result object as their first parameter, but the `KeyFieldsContext` parameter now provides `context.storeObject` (the `StoreObject` just processed by `processSelectionSet`) and `context.readField` (a helper function for reading fields from `context.storeObject` and any `Reference`s it might contain, similar to `readField` for `read`, `merge`, and `cache.modify` functions). <br/>
[@benjamn](https://github.com/benjamn) in [#8996](https://github.com/apollographql/apollo-client/pull/8996)

- Ensure `cache.identify` never throws when primary key fields are missing, and include the source object in the error message when `keyFields` processing fails. <br/>
[@benjamn](https://github.com/benjamn) in [#8679](https://github.com/apollographql/apollo-client/pull/8679)

- The `HttpLink` constructor now accepts an optional `print` function that can be used to customize how GraphQL `DocumentNode` objects are transformed back into strings before they are sent over the network. <br/>
[@sarahgp](https://github.com/sarahgp) in [#8699](https://github.com/apollographql/apollo-client/pull/8699)

- Make `@apollo/client/testing` a fully-fledged, independent entry point, instead of re-exporting `@apollo/client/utilities/testing` (which was never an entry point and no longer exists). <br/>
[@benjamn](https://github.com/benjamn) in [#8769](https://github.com/apollographql/apollo-client/pull/8769)

- A new nested entry point called `@apollo/client/testing/core` has been created. Importing from this entry point instead of `@apollo/client/testing` excludes any React-related dependencies. <br/>
[@wassim-k](https://github.com/wassim-k) in [#8687](https://github.com/apollographql/apollo-client/pull/8687)

- Make `cache.batch` return the result of calling the `options.update` function. <br/>
[@benjamn](https://github.com/benjamn) in [#8696](https://github.com/apollographql/apollo-client/pull/8696)

- The `NetworkError` and `ErrorResponse` types have been changed to align more closely. <br/>
[@korywka](https://github.com/korywka) in [#8424](https://github.com/apollographql/apollo-client/pull/8424)

- Include `graphql@16` in peer deps. <br/>
[@brainkim](https://github.com/brainkim) in [#8997](https://github.com/apollographql/apollo-client/pull/8997)

### React Refactoring

#### Improvements (due to [@brainkim](https://github.com/brainkim) in [#8875](https://github.com/apollographql/apollo-client/pull/8875)):
- The `useLazyQuery` function now returns a promise with the result.
- The `useMutation` result now exposes a method which can be reset.

#### Bug Fixes (due to [@brainkim](https://github.com/brainkim) in [#8596](https://github.com/apollographql/apollo-client/pull/8596)):

- The `useQuery` and `useLazyQuery` hooks will now have `ObservableQuery` methods defined consistently.
- Calling `useLazyQuery` methods like `startPolling` will start the query.
- Calling the `useLazyQuery` execution function will now behave more like `refetch`. `previousData` will be preserved.
- `standby` fetchPolicies will now act like `skip: true` more consistently.
- Calling `refetch` on a skipped query will have no effect (issue [#8270](https://github.com/apollographql/apollo-client/issues/8270)).
- Prevent `onError` and `onCompleted` functions from firing continuously, and improving their polling behavior.

### Other Bugs Fixed

- Update `zen-observable-ts` to eliminate transitive dependency on `@types/zen-observable`. <br/>
[@benjamn](https://github.com/benjamn) in [#8695](https://github.com/apollographql/apollo-client/pull/8695)

## Apollo Client 3.4.17 (2021-11-08)

### Improvements
Expand Down
4 changes: 2 additions & 2 deletions config/entryPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ const entryPoints = [
{ dirs: ['react'] },
{ dirs: ['react', 'components'] },
{ dirs: ['react', 'context'] },
{ dirs: ['react', 'data'] },
{ dirs: ['react', 'hoc'] },
{ dirs: ['react', 'hooks'] },
{ dirs: ['react', 'parser'] },
{ dirs: ['react', 'ssr'] },
{ dirs: ['testing'], extensions: [".js", ".jsx"] },
{ dirs: ['testing', 'core'] },
{ dirs: ['utilities'] },
{ dirs: ['utilities', 'globals'], sideEffects: true },
{ dirs: ['testing'], extensions: [".js", ".jsx"] },
];

const lookupTrie = Object.create(null);
Expand Down
1 change: 1 addition & 0 deletions config/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function eachFile(dir: string, callback: (

// Avoid re-transforming CommonJS bundle files.
if (relPath.endsWith(".cjs.js")) return;
if (relPath.endsWith(".cjs")) return;

// Avoid re-transforming CommonJS bundle files.
if (relPath.endsWith(".min.js")) return;
Expand Down
1 change: 1 addition & 0 deletions config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ module.exports = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
testURL: 'http://localhost',
setupFiles: ['<rootDir>/config/jest/setup.ts'],
testEnvironment: 'jsdom',
};
9 changes: 8 additions & 1 deletion config/prepareDist.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const distRoot = `${__dirname}/../dist`;
const packageJson = require('../package.json');
const entryPoints = require('./entryPoints.js');

// Enable default interpretation of .js files as ECMAScript modules. We don't
// put this in the source ../package.json file because it interferes with tools
// like ts-node, which we use to run various ../config/*.ts scripts.
// TODO(benjamn) Fully diagnose that interference.
packageJson.type = 'module';

// The root package.json is marked as private to prevent publishing
// from happening in the root of the project. This sets the package back to
// public so it can be published from the "dist" directory.
Expand Down Expand Up @@ -70,7 +76,8 @@ entryPoints.forEach(function buildPackageJson({
path.join(distRoot, ...dirs, 'package.json'),
JSON.stringify({
name: path.posix.join('@apollo', 'client', ...dirs),
main: `${bundleName}.cjs.js`,
type: "module",
main: `${bundleName}.cjs`,
module: 'index.js',
types: 'index.d.ts',
sideEffects,
Expand Down
32 changes: 28 additions & 4 deletions config/resolveModuleIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,45 @@ class Transformer {
return id.startsWith("./") || id.startsWith("../");
}

normalizeSourceString(file: string, source: Node | null | undefined) {
if (source && n.StringLiteral.check(source) && this.isRelative(source.value)) {
normalizeSourceString(file: string, source?: Node | null) {
if (source && n.StringLiteral.check(source)) {
try {
source.value = this.normalizeId(source.value, file);
source.value = this.isRelative(source.value)
? this.normalizeId(source.value, file)
: this.normalizeNonRelativeId(source.value, file);
} catch (error) {
console.error(`Failed to resolve ${source.value} in ${file}`);
console.error(`Failed to resolve ${source.value} in ${file} with error ${error}`);
process.exit(1);
}
}
}

normalizeNonRelativeId(id: string, file: string) {
const normal = this.normalizeId(id, file);
const normalParts = normal.split("/");
const sourceParts = id.split("/");
const nodeModulesIndex = normalParts.lastIndexOf("node_modules");
if (
nodeModulesIndex >= 0 &&
normalParts[nodeModulesIndex + 1] === sourceParts[0]
) {
const bareModuleIdentifier =
normalParts.slice(nodeModulesIndex + 1).join("/");
if (normal === this.normalizeId(bareModuleIdentifier, file)) {
return bareModuleIdentifier;
}
console.error(`Leaving ${id} import in ${file} unchanged because ${
bareModuleIdentifier
} does not resolve to the same module`);
}
return id;
}

normalizeId(id: string, file: string) {
const basedir = path.dirname(file);
const absPath = resolve.sync(id, {
basedir,
extensions: [".mjs", ".js"],
packageFilter(pkg) {
return pkg.module ? {
...pkg,
Expand Down
8 changes: 4 additions & 4 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function prepareCJSMinified(input) {
return {
input,
output: {
file: input.replace('.js', '.min.js'),
file: input.replace('.cjs', '.min.cjs'),
format: 'cjs',
},
plugins: [
Expand Down Expand Up @@ -108,7 +108,7 @@ function prepareBundle({
return isExternal(id, parentId, true);
},
output: {
file: `${dir}/${bundleName}.cjs.js`,
file: `${dir}/${bundleName}.cjs`,
format: 'cjs',
sourcemap: true,
exports: 'named',
Expand All @@ -125,9 +125,9 @@ export default [
// Convert the ESM entry point to a single CJS bundle.
prepareCJS(
'./dist/index.js',
'./dist/apollo-client.cjs.js',
'./dist/apollo-client.cjs',
),
prepareCJSMinified(
'./dist/apollo-client.cjs.js',
'./dist/apollo-client.cjs',
),
];
16 changes: 8 additions & 8 deletions config/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ switch (process.argv[2]) {
const {
ApolloClient,
InMemoryCache,
} = require(path.join(distRoot, "core", "core.cjs.js"));
} = require(path.join(distRoot, "core", "core.cjs"));

// Though this may seem like overkill, verifying that ApolloClient is
// constructible in Node.js is actually pretty useful, too!
Expand All @@ -43,15 +43,15 @@ switch (process.argv[2]) {
// the client might have acquired during its construction.
client.stop();

// The CommonJS dist/core/core.cjs.js file is generated from ESM modules
// generated by tsc, including dist/version.js, so verifying core.cjs.js
// exports an ApolloClient class that defines client.version also serves
// to verify that dist/version.js must have been correctly updated,
// which is convenient because dist/version.js uses ECMAScript module
// syntax, and is thus not importable in all versions of Node.js.
// The CommonJS dist/core/core.cjs file is generated from ESM modules
// generated by tsc, including dist/version.js, so verifying core.cjs
// exports an ApolloClient class that defines client.version also serves to
// verify that dist/version.js must have been correctly updated, which is
// convenient because dist/version.js uses ECMAScript module syntax, and is
// thus not importable in all versions of Node.js.
assert.strictEqual(
client.version, version,
"Failed to update dist/version.js and dist/core/core.cjs.js",
"Failed to update dist/version.js and dist/core/core.cjs",
);

break;
Expand Down
Loading