@apollo/client 3.9.0-beta.0 → 3.9.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.changeset/chatty-comics-yawn.md +8 -0
  2. package/.changeset/curvy-seas-hope.md +13 -0
  3. package/.changeset/late-rabbits-protect.md +7 -0
  4. package/.changeset/pre.json +6 -0
  5. package/.changeset/smooth-plums-shout.md +5 -0
  6. package/.changeset/spicy-drinks-camp.md +5 -0
  7. package/.changeset/wise-news-grab.md +7 -0
  8. package/CHANGELOG.md +33 -0
  9. package/apollo-client.cjs +9 -7
  10. package/apollo-client.cjs.map +1 -1
  11. package/apollo-client.min.cjs +1 -1
  12. package/core/ApolloClient.d.ts +74 -1
  13. package/core/ApolloClient.js.map +1 -1
  14. package/core/ObservableQuery.js +8 -4
  15. package/core/ObservableQuery.js.map +1 -1
  16. package/core/core.cjs +9 -5
  17. package/core/core.cjs.map +1 -1
  18. package/core/core.cjs.native.js +9 -5
  19. package/dev/dev.cjs +1 -1
  20. package/dev/dev.cjs.map +1 -1
  21. package/dev/dev.cjs.native.js +1 -1
  22. package/link/retry/retry.cjs +15 -74
  23. package/link/retry/retry.cjs.map +1 -1
  24. package/link/retry/retry.cjs.native.js +15 -74
  25. package/link/retry/retryLink.js +15 -93
  26. package/link/retry/retryLink.js.map +1 -1
  27. package/package.json +1 -1
  28. package/react/components/Mutation.d.ts +6 -0
  29. package/react/components/Mutation.js +6 -0
  30. package/react/components/Mutation.js.map +1 -1
  31. package/react/components/Query.d.ts +6 -0
  32. package/react/components/Query.js +6 -0
  33. package/react/components/Query.js.map +1 -1
  34. package/react/components/Subscription.d.ts +6 -0
  35. package/react/components/Subscription.js +6 -0
  36. package/react/components/Subscription.js.map +1 -1
  37. package/react/components/components.cjs.map +1 -1
  38. package/react/hoc/graphql.d.ts +5 -0
  39. package/react/hoc/graphql.js +5 -0
  40. package/react/hoc/graphql.js.map +1 -1
  41. package/react/hoc/hoc.cjs.map +1 -1
  42. package/react/hoc/mutation-hoc.d.ts +5 -0
  43. package/react/hoc/mutation-hoc.js +5 -0
  44. package/react/hoc/mutation-hoc.js.map +1 -1
  45. package/react/hoc/query-hoc.d.ts +5 -0
  46. package/react/hoc/query-hoc.js +5 -0
  47. package/react/hoc/query-hoc.js.map +1 -1
  48. package/react/hoc/subscription-hoc.d.ts +5 -0
  49. package/react/hoc/subscription-hoc.js +5 -0
  50. package/react/hoc/subscription-hoc.js.map +1 -1
  51. package/react/hoc/withApollo.d.ts +5 -0
  52. package/react/hoc/withApollo.js +5 -0
  53. package/react/hoc/withApollo.js.map +1 -1
  54. package/react/hooks/hooks.cjs +23 -292
  55. package/react/hooks/hooks.cjs.map +1 -1
  56. package/react/hooks/hooks.cjs.native.js +23 -292
  57. package/react/hooks/useBackgroundQuery.d.ts +1 -1
  58. package/react/hooks/useBackgroundQuery.js +1 -3
  59. package/react/hooks/useBackgroundQuery.js.map +1 -1
  60. package/react/hooks/useLoadableQuery.d.ts +1 -1
  61. package/react/hooks/useLoadableQuery.js +1 -3
  62. package/react/hooks/useLoadableQuery.js.map +1 -1
  63. package/react/hooks/useQueryRefHandlers.d.ts +1 -1
  64. package/react/hooks/useQueryRefHandlers.js +1 -1
  65. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  66. package/react/hooks/useReadQuery.d.ts +1 -1
  67. package/react/hooks/useReadQuery.js +1 -1
  68. package/react/hooks/useReadQuery.js.map +1 -1
  69. package/react/hooks/useSuspenseQuery.js +1 -1
  70. package/react/hooks/useSuspenseQuery.js.map +1 -1
  71. package/react/{cache → internal/cache}/QueryReference.d.ts +2 -2
  72. package/react/{cache → internal/cache}/QueryReference.js +2 -2
  73. package/react/internal/cache/QueryReference.js.map +1 -0
  74. package/react/{cache → internal/cache}/SuspenseCache.d.ts +1 -1
  75. package/react/{cache → internal/cache}/SuspenseCache.js +1 -1
  76. package/react/internal/cache/SuspenseCache.js.map +1 -0
  77. package/react/{cache → internal/cache}/getSuspenseCache.d.ts +3 -3
  78. package/react/internal/cache/getSuspenseCache.js.map +1 -0
  79. package/react/internal/cache/types.js.map +1 -0
  80. package/react/internal/index.d.ts +6 -0
  81. package/react/internal/index.js +3 -0
  82. package/react/internal/index.js.map +1 -0
  83. package/react/internal/internal.cjs +283 -0
  84. package/react/internal/internal.cjs.map +1 -0
  85. package/react/internal/internal.cjs.native.js +283 -0
  86. package/react/internal/package.json +8 -0
  87. package/react/query-preloader/createQueryPreloader.d.ts +1 -1
  88. package/react/query-preloader/createQueryPreloader.js +1 -1
  89. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  90. package/react/react.cjs +3 -238
  91. package/react/react.cjs.map +1 -1
  92. package/react/react.cjs.native.js +3 -238
  93. package/react/types/types.d.ts +1 -1
  94. package/react/types/types.js.map +1 -1
  95. package/testing/internal/ObservableStream.js +16 -8
  96. package/testing/internal/ObservableStream.js.map +1 -1
  97. package/testing/internal/scenarios/index.js +5 -3
  98. package/testing/internal/scenarios/index.js.map +1 -1
  99. package/testing/matchers/toBeDisposed.js +1 -1
  100. package/testing/matchers/toBeDisposed.js.map +1 -1
  101. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
  102. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  103. package/utilities/caching/sizes.d.ts +107 -57
  104. package/utilities/caching/sizes.js.map +1 -1
  105. package/utilities/globals/globals.cjs +1 -1
  106. package/utilities/globals/globals.cjs.map +1 -1
  107. package/utilities/globals/globals.cjs.native.js +1 -1
  108. package/version.js +1 -1
  109. package/react/cache/QueryReference.js.map +0 -1
  110. package/react/cache/SuspenseCache.js.map +0 -1
  111. package/react/cache/getSuspenseCache.js.map +0 -1
  112. package/react/cache/index.d.ts +0 -3
  113. package/react/cache/index.js +0 -2
  114. package/react/cache/index.js.map +0 -1
  115. package/react/cache/types.js.map +0 -1
  116. /package/react/{cache → internal/cache}/getSuspenseCache.js +0 -0
  117. /package/react/{cache → internal/cache}/types.d.ts +0 -0
  118. /package/react/{cache → internal/cache}/types.js +0 -0
@@ -0,0 +1,8 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Adds a deprecation warning to the HOC and render prop APIs.
6
+
7
+ The HOC and render prop APIs have already been deprecated since 2020,
8
+ but we previously didn't have a @deprecated tag in the DocBlocks.
@@ -0,0 +1,13 @@
1
+ ---
2
+ "@apollo/client": minor
3
+ ---
4
+
5
+ Simplify RetryLink, fix potential memory leak
6
+
7
+ Historically, `RetryLink` would keep a `values` array of all previous values,
8
+ in case the operation would get an additional subscriber at a later point in time.
9
+ In practice, this could lead to a memory leak (#11393) and did not serve any
10
+ further purpose, as the resulting observable would only be subscribed to by
11
+ Apollo Client itself, and only once - it would be wrapped in a `Concast` before
12
+ being exposed to the user, and that `Concast` would handle subscribers on its
13
+ own.
@@ -0,0 +1,7 @@
1
+ ---
2
+ '@apollo/client': minor
3
+ ---
4
+
5
+ Remove the need to call `retain` from `useLoadableQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you.
6
+
7
+ Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed.
@@ -7,13 +7,16 @@
7
7
  "changesets": [
8
8
  "beige-geese-wink",
9
9
  "breezy-spiders-tap",
10
+ "chatty-comics-yawn",
10
11
  "clean-items-smash",
11
12
  "cold-llamas-turn",
13
+ "curvy-seas-hope",
12
14
  "dirty-kids-crash",
13
15
  "dirty-tigers-matter",
14
16
  "forty-cups-shop",
15
17
  "friendly-clouds-laugh",
16
18
  "hot-ducks-burn",
19
+ "late-rabbits-protect",
17
20
  "mighty-coats-check",
18
21
  "polite-avocados-warn",
19
22
  "quick-hats-marry",
@@ -21,7 +24,9 @@
21
24
  "shaggy-ears-scream",
22
25
  "shaggy-sheep-pull",
23
26
  "sixty-boxes-rest",
27
+ "smooth-plums-shout",
24
28
  "sour-sheep-walk",
29
+ "spicy-drinks-camp",
25
30
  "strong-terms-perform",
26
31
  "swift-zoos-collect",
27
32
  "thick-mice-collect",
@@ -32,6 +37,7 @@
32
37
  "violet-lions-draw",
33
38
  "wet-forks-rhyme",
34
39
  "wild-dolphins-jog",
40
+ "wise-news-grab",
35
41
  "yellow-flies-repeat"
36
42
  ]
37
43
  }
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ ObservableQuery: prevent reporting results of previous queries if the variables changed since
@@ -0,0 +1,5 @@
1
+ ---
2
+ '@apollo/client': patch
3
+ ---
4
+
5
+ Address bundling issue introduced in [#11412](https://github.com/apollographql/apollo-client/pull/11412) where the `react/cache` internals ended up duplicated in the bundle. This was due to the fact that we had a `react/hooks` entrypoint that imported these files along with the newly introduced `createQueryPreloader` function, which lived outside of the `react/hooks` folder.
@@ -0,0 +1,7 @@
1
+ ---
2
+ '@apollo/client': minor
3
+ ---
4
+
5
+ Remove the need to call `retain` from `useBackgroundQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you.
6
+
7
+ Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.9.0-beta.1
4
+
5
+ ### Minor Changes
6
+
7
+ - [#11424](https://github.com/apollographql/apollo-client/pull/11424) [`62f3b6d`](https://github.com/apollographql/apollo-client/commit/62f3b6d0e89611e27d9f29812ee60e5db5963fd6) Thanks [@phryneas](https://github.com/phryneas)! - Simplify RetryLink, fix potential memory leak
8
+
9
+ Historically, `RetryLink` would keep a `values` array of all previous values,
10
+ in case the operation would get an additional subscriber at a later point in time.
11
+ In practice, this could lead to a memory leak (#11393) and did not serve any
12
+ further purpose, as the resulting observable would only be subscribed to by
13
+ Apollo Client itself, and only once - it would be wrapped in a `Concast` before
14
+ being exposed to the user, and that `Concast` would handle subscribers on its
15
+ own.
16
+
17
+ - [#11442](https://github.com/apollographql/apollo-client/pull/11442) [`4b6f2bc`](https://github.com/apollographql/apollo-client/commit/4b6f2bccf3ba94643b38689b32edd2839e47aec1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the need to call `retain` from `useLoadableQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you.
18
+
19
+ Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed.
20
+
21
+ - [#11438](https://github.com/apollographql/apollo-client/pull/11438) [`6d46ab9`](https://github.com/apollographql/apollo-client/commit/6d46ab930a5e9bd5cae153d3b75b8966784fcd4e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove the need to call `retain` from `useBackgroundQuery` since `useReadQuery` will now retain the query. This means that a `queryRef` that is not consumed by `useReadQuery` within the given `autoDisposeTimeoutMs` will now be auto diposed for you.
22
+
23
+ Thanks to [#11412](https://github.com/apollographql/apollo-client/pull/11412), disposed query refs will be automatically resubscribed to the query when consumed by `useReadQuery` after it has been disposed.
24
+
25
+ ### Patch Changes
26
+
27
+ - [#11443](https://github.com/apollographql/apollo-client/pull/11443) [`ff5a332`](https://github.com/apollographql/apollo-client/commit/ff5a332ff8b190c418df25371e36719d70061ebe) Thanks [@phryneas](https://github.com/phryneas)! - Adds a deprecation warning to the HOC and render prop APIs.
28
+
29
+ The HOC and render prop APIs have already been deprecated since 2020,
30
+ but we previously didn't have a @deprecated tag in the DocBlocks.
31
+
32
+ - [#11078](https://github.com/apollographql/apollo-client/pull/11078) [`14edebe`](https://github.com/apollographql/apollo-client/commit/14edebebefb7634c32b921d02c1c85c6c8737989) Thanks [@phryneas](https://github.com/phryneas)! - ObservableQuery: prevent reporting results of previous queries if the variables changed since
33
+
34
+ - [#11439](https://github.com/apollographql/apollo-client/pull/11439) [`33454f0`](https://github.com/apollographql/apollo-client/commit/33454f0a40a05ea2b00633bda20a84d0ec3a4f4d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Address bundling issue introduced in [#11412](https://github.com/apollographql/apollo-client/pull/11412) where the `react/cache` internals ended up duplicated in the bundle. This was due to the fact that we had a `react/hooks` entrypoint that imported these files along with the newly introduced `createQueryPreloader` function, which lived outside of the `react/hooks` folder.
35
+
3
36
  ## 3.9.0-beta.0
4
37
 
5
38
  ### Minor Changes
package/apollo-client.cjs CHANGED
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
31
31
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
32
32
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
33
 
34
- var version = "3.9.0-beta.0";
34
+ var version = "3.9.0-beta.1";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -5294,12 +5294,16 @@ var ObservableQuery = (function (_super) {
5294
5294
  var _a = this.fetch(options, newNetworkStatus, query), concast = _a.concast, fromLink = _a.fromLink;
5295
5295
  var observer = {
5296
5296
  next: function (result) {
5297
- finishWaitingForOwnResult();
5298
- _this.reportResult(result, variables);
5297
+ if (equal.equal(_this.variables, variables)) {
5298
+ finishWaitingForOwnResult();
5299
+ _this.reportResult(result, variables);
5300
+ }
5299
5301
  },
5300
5302
  error: function (error) {
5301
- finishWaitingForOwnResult();
5302
- _this.reportError(error, variables);
5303
+ if (equal.equal(_this.variables, variables)) {
5304
+ finishWaitingForOwnResult();
5305
+ _this.reportError(error, variables);
5306
+ }
5303
5307
  },
5304
5308
  };
5305
5309
  if (!useDisposableConcast && (fromLink || !this.concast)) {
@@ -8458,7 +8462,6 @@ function useBackgroundQuery(query, options) {
8458
8462
  var promise = queryRef.applyOptions(watchQueryOptions);
8459
8463
  updateWrappedQueryRef(wrappedQueryRef, promise);
8460
8464
  }
8461
- React__namespace.useEffect(function () { return queryRef.retain(); }, [queryRef]);
8462
8465
  var fetchMore = React__namespace.useCallback(function (options) {
8463
8466
  var promise = queryRef.fetchMore(options);
8464
8467
  setWrappedQueryRef(wrapQueryRef(queryRef));
@@ -8488,7 +8491,6 @@ function useLoadableQuery(query, options) {
8488
8491
  updateWrappedQueryRef(queryRef, promise);
8489
8492
  }
8490
8493
  var calledDuringRender = useRenderGuard();
8491
- React__namespace.useEffect(function () { return internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.retain(); }, [internalQueryRef]);
8492
8494
  var fetchMore = React__namespace.useCallback(function (options) {
8493
8495
  if (!internalQueryRef) {
8494
8496
  throw new Error("The query has not been loaded. Please load the query.");