@apollo/client 3.9.7 → 3.9.9

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 (49) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/apollo-client.cjs +28 -5
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/core/ApolloClient.d.ts +7 -7
  6. package/core/ApolloClient.js +6 -6
  7. package/core/ApolloClient.js.map +1 -1
  8. package/core/core.cjs +1 -1
  9. package/core/core.cjs.map +1 -1
  10. package/core/core.cjs.native.js +1 -1
  11. package/core/watchQueryOptions.d.ts +3 -3
  12. package/dev/dev.cjs +18 -15
  13. package/dev/dev.cjs.map +1 -1
  14. package/dev/dev.cjs.native.js +18 -15
  15. package/dev/index.d.ts +2 -0
  16. package/dev/index.js +1 -0
  17. package/dev/index.js.map +1 -1
  18. package/dev/loadErrorMessageHandler.d.ts +6 -1
  19. package/dev/loadErrorMessageHandler.js +17 -14
  20. package/dev/loadErrorMessageHandler.js.map +1 -1
  21. package/dev/setErrorMessageHandler.d.ts +34 -0
  22. package/dev/setErrorMessageHandler.js +9 -0
  23. package/dev/setErrorMessageHandler.js.map +1 -0
  24. package/package.json +17 -17
  25. package/react/hooks/hooks.cjs +4 -0
  26. package/react/hooks/hooks.cjs.map +1 -1
  27. package/react/hooks/hooks.cjs.native.js +4 -0
  28. package/react/hooks/useBackgroundQuery.js +1 -0
  29. package/react/hooks/useBackgroundQuery.js.map +1 -1
  30. package/react/hooks/useFragment.d.ts +1 -1
  31. package/react/hooks/useFragment.js +5 -0
  32. package/react/hooks/useFragment.js.map +1 -1
  33. package/react/internal/cache/QueryReference.d.ts +4 -2
  34. package/react/internal/cache/QueryReference.js +34 -4
  35. package/react/internal/cache/QueryReference.js.map +1 -1
  36. package/react/internal/internal.cjs +23 -4
  37. package/react/internal/internal.cjs.map +1 -1
  38. package/react/internal/internal.cjs.native.js +23 -4
  39. package/react/query-preloader/createQueryPreloader.d.ts +6 -6
  40. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  41. package/react/types/types.d.ts +3 -3
  42. package/react/types/types.documentation.d.ts +4 -4
  43. package/react/types/types.documentation.js.map +1 -1
  44. package/utilities/globals/globals.cjs +1 -1
  45. package/utilities/globals/globals.cjs.map +1 -1
  46. package/utilities/globals/globals.cjs.native.js +1 -1
  47. package/utilities/globals/invariantWrappers.d.ts +1 -1
  48. package/utilities/globals/invariantWrappers.js.map +1 -1
  49. package/version.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.9.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11696](https://github.com/apollographql/apollo-client/pull/11696) [`466ef82`](https://github.com/apollographql/apollo-client/commit/466ef82198486fc696da64d17d82b46140760ac4) Thanks [@PiR1](https://github.com/PiR1)! - Immediately dispose of the `queryRef` if `useBackgroundQuery` unmounts before the auto dispose timeout kicks in.
8
+
9
+ ## 3.9.8
10
+
11
+ ### Patch Changes
12
+
13
+ - [#11706](https://github.com/apollographql/apollo-client/pull/11706) [`8619bc7`](https://github.com/apollographql/apollo-client/commit/8619bc7e569c1c732afa6faf605c83a6ce0cdf0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue in all suspense hooks where returning an empty array after calling `fetchMore` would rerender the component with an empty list.
14
+
15
+ - [#11694](https://github.com/apollographql/apollo-client/pull/11694) [`835d5f3`](https://github.com/apollographql/apollo-client/commit/835d5f30c532c432e2434561580e6f1ec44cc908) Thanks [@phryneas](https://github.com/phryneas)! - Expose `setErrorMessageHandler` from `@apollo/client/dev` entrypoint.
16
+
17
+ - [#11689](https://github.com/apollographql/apollo-client/pull/11689) [`cb8ffe5`](https://github.com/apollographql/apollo-client/commit/cb8ffe50e903397f741b62a44624bfe69b5f7b75) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where passing a new `from` option to `useFragment` would first render with the previous value before rerendering with the correct value.
18
+
19
+ - [#11713](https://github.com/apollographql/apollo-client/pull/11713) [`642092c`](https://github.com/apollographql/apollo-client/commit/642092c713199093aede45f105a1ee3f637614cd) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where setting a default `watchQuery` option in the `ApolloClient` constructor could break `startTransition` when used with suspense hooks.
20
+
3
21
  ## 3.9.7
4
22
 
5
23
  ### 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.9.7";
34
+ var version = "3.9.9";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -8048,6 +8048,9 @@ function _useFragment(options) {
8048
8048
  var resultRef = useLazyRef(function () {
8049
8049
  return diffToResult(cache.diff(diffOptions));
8050
8050
  });
8051
+ React__namespace.useMemo(function () {
8052
+ resultRef.current = diffToResult(cache.diff(diffOptions));
8053
+ }, [diffOptions, cache]);
8051
8054
  var getSnapshot = React__namespace.useCallback(function () { return resultRef.current; }, []);
8052
8055
  return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
8053
8056
  var lastTimeout = 0;
@@ -8115,6 +8118,7 @@ var InternalQueryReference = (function () {
8115
8118
  this.key = {};
8116
8119
  this.listeners = new Set();
8117
8120
  this.references = 0;
8121
+ this.softReferences = 0;
8118
8122
  this.handleNext = this.handleNext.bind(this);
8119
8123
  this.handleError = this.handleError.bind(this);
8120
8124
  this.dispose = this.dispose.bind(this);
@@ -8186,10 +8190,28 @@ var InternalQueryReference = (function () {
8186
8190
  });
8187
8191
  };
8188
8192
  };
8193
+ InternalQueryReference.prototype.softRetain = function () {
8194
+ var _this = this;
8195
+ this.softReferences++;
8196
+ var disposed = false;
8197
+ return function () {
8198
+ if (disposed) {
8199
+ return;
8200
+ }
8201
+ disposed = true;
8202
+ _this.softReferences--;
8203
+ setTimeout(function () {
8204
+ if (!_this.softReferences && !_this.references) {
8205
+ _this.dispose();
8206
+ }
8207
+ });
8208
+ };
8209
+ };
8189
8210
  InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
8190
8211
  var _this = this;
8191
8212
  return OBSERVED_CHANGED_OPTIONS.some(function (option) {
8192
- return !equal.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
8213
+ return option in watchQueryOptions &&
8214
+ !equal.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
8193
8215
  });
8194
8216
  };
8195
8217
  InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
@@ -8275,12 +8297,12 @@ var InternalQueryReference = (function () {
8275
8297
  this.promise = this.createPendingPromise();
8276
8298
  this.promise.catch(function () { });
8277
8299
  returnedPromise
8278
- .then(function (result) {
8300
+ .then(function () {
8279
8301
  setTimeout(function () {
8280
8302
  var _a;
8281
8303
  if (_this.promise.status === "pending") {
8282
- _this.result = result;
8283
- (_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, result);
8304
+ _this.result = _this.observable.getCurrentResult();
8305
+ (_a = _this.resolve) === null || _a === void 0 ? void 0 : _a.call(_this, _this.result);
8284
8306
  }
8285
8307
  });
8286
8308
  })
@@ -8504,6 +8526,7 @@ function _useBackgroundQuery(query, options) {
8504
8526
  setWrappedQueryRef(wrapQueryRef(queryRef));
8505
8527
  return promise;
8506
8528
  }, [queryRef]);
8529
+ React__namespace.useEffect(function () { return queryRef.softRetain(); }, [queryRef]);
8507
8530
  return [
8508
8531
  didFetchResult.current ? wrappedQueryRef : void 0,
8509
8532
  { fetchMore: fetchMore, refetch: refetch },