@apollo/client 3.10.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
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
+
3
12
  ## 3.10.1
4
13
 
5
14
  ### Patch 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.1";
34
+ var version = "3.10.2";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -8225,9 +8225,11 @@ var InternalQueryReference = (function () {
8225
8225
  }
8226
8226
  disposed = true;
8227
8227
  _this.references--;
8228
- if (!_this.references) {
8229
- _this.dispose();
8230
- }
8228
+ setTimeout(function () {
8229
+ if (!_this.references) {
8230
+ _this.dispose();
8231
+ }
8232
+ });
8231
8233
  };
8232
8234
  };
8233
8235
  InternalQueryReference.prototype.softRetain = function () {
@@ -8453,12 +8455,6 @@ function _useSuspenseQuery(query, options) {
8453
8455
  dispose();
8454
8456
  };
8455
8457
  }, [queryRef]);
8456
- React__namespace.useEffect(function () {
8457
- if (queryRef.disposed) {
8458
- suspenseCache.add(cacheKey, queryRef);
8459
- queryRef.reinitialize();
8460
- }
8461
- });
8462
8458
  var skipResult = React__namespace.useMemo(function () {
8463
8459
  var error = toApolloError(queryRef.result);
8464
8460
  return {
@@ -8567,9 +8563,12 @@ function _useBackgroundQuery(query, options) {
8567
8563
  updateWrappedQueryRef(wrappedQueryRef, promise);
8568
8564
  }
8569
8565
  React__namespace.useEffect(function () {
8570
- if (queryRef.disposed) {
8571
- suspenseCache.add(cacheKey, queryRef);
8572
- }
8566
+ var id = setTimeout(function () {
8567
+ if (queryRef.disposed) {
8568
+ suspenseCache.add(cacheKey, queryRef);
8569
+ }
8570
+ });
8571
+ return function () { return clearTimeout(id); };
8573
8572
  });
8574
8573
  var fetchMore = React__namespace.useCallback(function (options) {
8575
8574
  var promise = queryRef.fetchMore(options);
@@ -8682,12 +8681,7 @@ function _useReadQuery(queryRef) {
8682
8681
  internalQueryRef.reinitialize();
8683
8682
  updateWrappedQueryRef(queryRef, internalQueryRef.promise);
8684
8683
  }
8685
- React__namespace.useEffect(function () {
8686
- if (internalQueryRef.disposed) {
8687
- internalQueryRef.reinitialize();
8688
- }
8689
- return internalQueryRef.retain();
8690
- }, [internalQueryRef]);
8684
+ React__namespace.useEffect(function () { return internalQueryRef.retain(); }, [internalQueryRef]);
8691
8685
  var promise = useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
8692
8686
  return internalQueryRef.listen(function (promise) {
8693
8687
  updateWrappedQueryRef(queryRef, promise);