@apollo/client 3.10.0 → 3.10.2

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 (46) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/apollo-client.cjs +20 -21
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/core/core.cjs +1 -1
  6. package/core/core.cjs.map +1 -1
  7. package/core/core.cjs.native.js +1 -1
  8. package/dev/dev.cjs +1 -1
  9. package/dev/dev.cjs.map +1 -1
  10. package/dev/dev.cjs.native.js +1 -1
  11. package/link/core/types.d.ts +4 -1
  12. package/link/core/types.js.map +1 -1
  13. package/link/http/selectURI.d.ts +1 -1
  14. package/link/utils/createOperation.js.map +1 -1
  15. package/package.json +8 -8
  16. package/react/hooks/hooks.cjs +7 -15
  17. package/react/hooks/hooks.cjs.map +1 -1
  18. package/react/hooks/hooks.cjs.native.js +7 -15
  19. package/react/hooks/useBackgroundQuery.js +13 -9
  20. package/react/hooks/useBackgroundQuery.js.map +1 -1
  21. package/react/hooks/useReadQuery.js +1 -10
  22. package/react/hooks/useReadQuery.js.map +1 -1
  23. package/react/hooks/useSuspenseQuery.js +0 -27
  24. package/react/hooks/useSuspenseQuery.js.map +1 -1
  25. package/react/internal/cache/QueryReference.js +5 -3
  26. package/react/internal/cache/QueryReference.js.map +1 -1
  27. package/react/internal/internal.cjs +5 -3
  28. package/react/internal/internal.cjs.map +1 -1
  29. package/react/internal/internal.cjs.native.js +5 -3
  30. package/react/ssr/RenderPromises.js +10 -15
  31. package/react/ssr/RenderPromises.js.map +1 -1
  32. package/react/ssr/ssr.cjs +8 -15
  33. package/react/ssr/ssr.cjs.map +1 -1
  34. package/react/ssr/ssr.cjs.native.js +8 -15
  35. package/testing/experimental/createSchemaFetch.d.ts +0 -1
  36. package/utilities/caching/caches.d.ts +2 -2
  37. package/utilities/caching/caches.js +9 -4
  38. package/utilities/caching/caches.js.map +1 -1
  39. package/utilities/globals/globals.cjs +1 -1
  40. package/utilities/globals/globals.cjs.map +1 -1
  41. package/utilities/globals/globals.cjs.native.js +1 -1
  42. package/utilities/subscriptions/urql/index.d.ts +1 -1
  43. package/utilities/utilities.cjs +7 -2
  44. package/utilities/utilities.cjs.map +1 -1
  45. package/utilities/utilities.cjs.native.js +7 -2
  46. package/version.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.10.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11821](https://github.com/apollographql/apollo-client/pull/11821) [`2675d3c`](https://github.com/apollographql/apollo-client/commit/2675d3c97e6c47c6e298382004c7c9c2d3ffed0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix a regression where rerendering a component with `useBackgroundQuery` would recreate the `queryRef` instance when used with React's strict mode.
8
+
9
+ - [#11821](https://github.com/apollographql/apollo-client/pull/11821) [`2675d3c`](https://github.com/apollographql/apollo-client/commit/2675d3c97e6c47c6e298382004c7c9c2d3ffed0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Revert the change introduced in
10
+ [3.9.10](https://github.com/apollographql/apollo-client/releases/tag/v3.9.10) via #11738 that disposed of queryRefs synchronously. This change caused too many issues with strict mode.
11
+
12
+ ## 3.10.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#11792](https://github.com/apollographql/apollo-client/pull/11792) [`5876c35`](https://github.com/apollographql/apollo-client/commit/5876c35530a21473207954d1f0c2b7dd00c0b9ea) Thanks [@phryneas](https://github.com/phryneas)! - AutoCleanedCache: only schedule batched cache cleanup if the cache is full (fixes #11790)
17
+
18
+ - [#11799](https://github.com/apollographql/apollo-client/pull/11799) [`1aca7ed`](https://github.com/apollographql/apollo-client/commit/1aca7ed5a3accf2303ccdf9b3dece7278f03ad62) Thanks [@phryneas](https://github.com/phryneas)! - `RenderPromises`: use `canonicalStringify` to serialize `variables` to ensure query deduplication is properly applied even when `variables` are specified in a different order.
19
+
20
+ - [#11803](https://github.com/apollographql/apollo-client/pull/11803) [`bf9dd17`](https://github.com/apollographql/apollo-client/commit/bf9dd17b288f33901e9421bcc0eacb3894c087af) Thanks [@phryneas](https://github.com/phryneas)! - Update the `rehackt` dependency to `^0.1.0`
21
+
22
+ - [#11756](https://github.com/apollographql/apollo-client/pull/11756) [`60592e9`](https://github.com/apollographql/apollo-client/commit/60592e95399c3695d1d49a4c39ad29f00d4059fd) Thanks [@henryqdineen](https://github.com/henryqdineen)! - Fix operation.setContext() type
23
+
3
24
  ## 3.10.0
4
25
 
5
26
  ### 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.10.0";
34
+ var version = "3.10.2";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -265,6 +265,9 @@ function getFragmentFromSelection(selection, fragmentMap) {
265
265
 
266
266
  var scheduledCleanup = new WeakSet();
267
267
  function schedule(cache) {
268
+ if (cache.size <= (cache.max || -1)) {
269
+ return;
270
+ }
268
271
  if (!scheduledCleanup.has(cache)) {
269
272
  scheduledCleanup.add(cache);
270
273
  setTimeout(function () {
@@ -276,16 +279,18 @@ function schedule(cache) {
276
279
  var AutoCleanedWeakCache = function (max, dispose) {
277
280
  var cache = new caches.WeakCache(max, dispose);
278
281
  cache.set = function (key, value) {
282
+ var ret = caches.WeakCache.prototype.set.call(this, key, value);
279
283
  schedule(this);
280
- return caches.WeakCache.prototype.set.call(this, key, value);
284
+ return ret;
281
285
  };
282
286
  return cache;
283
287
  };
284
288
  var AutoCleanedStrongCache = function (max, dispose) {
285
289
  var cache = new caches.StrongCache(max, dispose);
286
290
  cache.set = function (key, value) {
291
+ var ret = caches.StrongCache.prototype.set.call(this, key, value);
287
292
  schedule(this);
288
- return caches.StrongCache.prototype.set.call(this, key, value);
293
+ return ret;
289
294
  };
290
295
  return cache;
291
296
  };
@@ -8220,9 +8225,11 @@ var InternalQueryReference = (function () {
8220
8225
  }
8221
8226
  disposed = true;
8222
8227
  _this.references--;
8223
- if (!_this.references) {
8224
- _this.dispose();
8225
- }
8228
+ setTimeout(function () {
8229
+ if (!_this.references) {
8230
+ _this.dispose();
8231
+ }
8232
+ });
8226
8233
  };
8227
8234
  };
8228
8235
  InternalQueryReference.prototype.softRetain = function () {
@@ -8448,12 +8455,6 @@ function _useSuspenseQuery(query, options) {
8448
8455
  dispose();
8449
8456
  };
8450
8457
  }, [queryRef]);
8451
- React__namespace.useEffect(function () {
8452
- if (queryRef.disposed) {
8453
- suspenseCache.add(cacheKey, queryRef);
8454
- queryRef.reinitialize();
8455
- }
8456
- });
8457
8458
  var skipResult = React__namespace.useMemo(function () {
8458
8459
  var error = toApolloError(queryRef.result);
8459
8460
  return {
@@ -8562,9 +8563,12 @@ function _useBackgroundQuery(query, options) {
8562
8563
  updateWrappedQueryRef(wrappedQueryRef, promise);
8563
8564
  }
8564
8565
  React__namespace.useEffect(function () {
8565
- if (queryRef.disposed) {
8566
- suspenseCache.add(cacheKey, queryRef);
8567
- }
8566
+ var id = setTimeout(function () {
8567
+ if (queryRef.disposed) {
8568
+ suspenseCache.add(cacheKey, queryRef);
8569
+ }
8570
+ });
8571
+ return function () { return clearTimeout(id); };
8568
8572
  });
8569
8573
  var fetchMore = React__namespace.useCallback(function (options) {
8570
8574
  var promise = queryRef.fetchMore(options);
@@ -8677,12 +8681,7 @@ function _useReadQuery(queryRef) {
8677
8681
  internalQueryRef.reinitialize();
8678
8682
  updateWrappedQueryRef(queryRef, internalQueryRef.promise);
8679
8683
  }
8680
- React__namespace.useEffect(function () {
8681
- if (internalQueryRef.disposed) {
8682
- internalQueryRef.reinitialize();
8683
- }
8684
- return internalQueryRef.retain();
8685
- }, [internalQueryRef]);
8684
+ React__namespace.useEffect(function () { return internalQueryRef.retain(); }, [internalQueryRef]);
8686
8685
  var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
8687
8686
  return internalQueryRef.listen(function (promise) {
8688
8687
  updateWrappedQueryRef(queryRef, promise);