@apollo/client 3.8.8 → 3.8.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 (40) hide show
  1. package/CHANGELOG.md +15 -3
  2. package/apollo-client.cjs +46 -42
  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/http/checkFetcher.d.ts +1 -1
  12. package/link/http/checkFetcher.js.map +1 -1
  13. package/link/http/http.cjs +0 -3
  14. package/link/http/http.cjs.map +1 -1
  15. package/link/http/http.cjs.native.js +0 -3
  16. package/link/http/parseAndCheckHttpResponse.js +0 -4
  17. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  18. package/link/http/selectHttpOptionsAndBody.d.ts +1 -1
  19. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  20. package/package.json +32 -32
  21. package/react/hooks/hooks.cjs +45 -38
  22. package/react/hooks/hooks.cjs.map +1 -1
  23. package/react/hooks/hooks.cjs.native.js +45 -38
  24. package/react/hooks/internal/index.d.ts +1 -0
  25. package/react/hooks/internal/index.js +1 -0
  26. package/react/hooks/internal/index.js.map +1 -1
  27. package/react/hooks/internal/useLazyRef.d.ts +3 -0
  28. package/react/hooks/internal/useLazyRef.js +10 -0
  29. package/react/hooks/internal/useLazyRef.js.map +1 -0
  30. package/react/hooks/useFragment.js +20 -17
  31. package/react/hooks/useFragment.js.map +1 -1
  32. package/testing/core/core.cjs +4 -2
  33. package/testing/core/core.cjs.map +1 -1
  34. package/testing/core/core.cjs.native.js +4 -2
  35. package/testing/core/mocking/mockLink.js +8 -2
  36. package/testing/core/mocking/mockLink.js.map +1 -1
  37. package/utilities/globals/globals.cjs +1 -1
  38. package/utilities/globals/globals.cjs.map +1 -1
  39. package/utilities/globals/globals.cjs.native.js +1 -1
  40. package/version.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.8.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11472](https://github.com/apollographql/apollo-client/pull/11472) [`afc844d`](https://github.com/apollographql/apollo-client/commit/afc844dd8d6f9f7a3e2003f9a5b541291dfe3fb4) Thanks [@alessbell](https://github.com/alessbell)! - Fix delay: Infinity when set on a MockResponse passed to Mocked Provider so it indefinitely enters loading state.
8
+
9
+ - [#11464](https://github.com/apollographql/apollo-client/pull/11464) [`aac12b2`](https://github.com/apollographql/apollo-client/commit/aac12b221a6cb776d4941b6c8aadf04f0f0acd27) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Prevent `useFragment` from excessively unsubscribing and resubscribing the fragment with the cache on every render.
10
+
11
+ - [#11449](https://github.com/apollographql/apollo-client/pull/11449) [`f40cda4`](https://github.com/apollographql/apollo-client/commit/f40cda45841e93b056c781c19651b54464f7346a) Thanks [@phryneas](https://github.com/phryneas)! - Removes refences to the typescript "dom" lib.
12
+
13
+ - [#11470](https://github.com/apollographql/apollo-client/pull/11470) [`e293bc9`](https://github.com/apollographql/apollo-client/commit/e293bc90d6f7937a6fc7c169f7b16eeb39d5fd49) Thanks [@phryneas](https://github.com/phryneas)! - Remove an unnecessary check from parseAndCheckHttpResponse.
14
+
3
15
  ## 3.8.8
4
16
 
5
17
  ### Patch Changes
@@ -199,7 +211,7 @@
199
211
  return data.breeds.map(({ characteristics }) =>
200
212
  characteristics.map((characteristic) => (
201
213
  <div key={characteristic}>{characteristic}</div>
202
- ))
214
+ )),
203
215
  );
204
216
  }
205
217
  ```
@@ -250,7 +262,7 @@
250
262
 
251
263
  const { data } = useSuspenseQuery(
252
264
  query,
253
- id ? { variables: { id } } : skipToken
265
+ id ? { variables: { id } } : skipToken,
254
266
  );
255
267
  ```
256
268
 
@@ -2205,7 +2217,7 @@ In upcoming v3.6.x and v3.7 (beta) releases, we will be completely overhauling o
2205
2217
  fields: {
2206
2218
  comments(comments: Reference[], { readField }) {
2207
2219
  return comments.filter(
2208
- (comment) => idToRemove !== readField("id", comment)
2220
+ (comment) => idToRemove !== readField("id", comment),
2209
2221
  );
2210
2222
  },
2211
2223
  },
package/apollo-client.cjs CHANGED
@@ -30,7 +30,7 @@ function _interopNamespace(e) {
30
30
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
31
31
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
32
 
33
- var version = "3.8.8";
33
+ var version = "3.8.9";
34
34
 
35
35
  function maybe(thunk) {
36
36
  try {
@@ -1894,9 +1894,6 @@ function parseAndCheckHttpResponse(operations) {
1894
1894
  .text()
1895
1895
  .then(function (bodyText) { return parseJsonBody(response, bodyText); })
1896
1896
  .then(function (result) {
1897
- if (response.status >= 300) {
1898
- throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
1899
- }
1900
1897
  if (!Array.isArray(result) &&
1901
1898
  !hasOwnProperty$3.call(result, "data") &&
1902
1899
  !hasOwnProperty$3.call(result, "errors")) {
@@ -7769,44 +7766,6 @@ function useReactiveVar(rv) {
7769
7766
  }, [rv]), rv, rv);
7770
7767
  }
7771
7768
 
7772
- function useFragment(options) {
7773
- var cache = useApolloClient().cache;
7774
- var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
7775
- var diffOptions = tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
7776
- var resultRef = React__namespace.useRef();
7777
- var latestDiff = cache.diff(diffOptions);
7778
- var getSnapshot = function () {
7779
- var latestDiffToResult = diffToResult(latestDiff);
7780
- return (resultRef.current &&
7781
- equal.equal(resultRef.current.data, latestDiffToResult.data)) ?
7782
- resultRef.current
7783
- : (resultRef.current = latestDiffToResult);
7784
- };
7785
- return useSyncExternalStore(function (forceUpdate) {
7786
- var lastTimeout = 0;
7787
- var unsubcribe = cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
7788
- if (!equal.equal(diff, latestDiff)) {
7789
- resultRef.current = diffToResult((latestDiff = diff));
7790
- lastTimeout = setTimeout(forceUpdate);
7791
- }
7792
- } }));
7793
- return function () {
7794
- unsubcribe();
7795
- clearTimeout(lastTimeout);
7796
- };
7797
- }, getSnapshot, getSnapshot);
7798
- }
7799
- function diffToResult(diff) {
7800
- var result = {
7801
- data: diff.result,
7802
- complete: !!diff.complete,
7803
- };
7804
- if (diff.missing) {
7805
- result.missing = mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
7806
- }
7807
- return result;
7808
- }
7809
-
7810
7769
  function useDeepMemo(memoFn, deps) {
7811
7770
  var ref = React__namespace.useRef();
7812
7771
  if (!ref.current || !equal.equal(ref.current.deps, deps)) {
@@ -7815,6 +7774,15 @@ function useDeepMemo(memoFn, deps) {
7815
7774
  return ref.current.value;
7816
7775
  }
7817
7776
 
7777
+ var INIT = {};
7778
+ function useLazyRef(getInitialValue) {
7779
+ var ref = React__namespace.useRef(INIT);
7780
+ if (ref.current === INIT) {
7781
+ ref.current = getInitialValue();
7782
+ }
7783
+ return ref;
7784
+ }
7785
+
7818
7786
  var useKey = "use";
7819
7787
  var realHook = React__namespace[useKey];
7820
7788
  var __use = realHook ||
@@ -7830,6 +7798,42 @@ var __use = realHook ||
7830
7798
  }
7831
7799
  };
7832
7800
 
7801
+ function useFragment(options) {
7802
+ var cache = useApolloClient().cache;
7803
+ var diffOptions = useDeepMemo(function () {
7804
+ var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, rest = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
7805
+ return tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
7806
+ }, [options]);
7807
+ var resultRef = useLazyRef(function () {
7808
+ return diffToResult(cache.diff(diffOptions));
7809
+ });
7810
+ var getSnapshot = React__namespace.useCallback(function () { return resultRef.current; }, []);
7811
+ return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
7812
+ var lastTimeout = 0;
7813
+ var unsubscribe = cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
7814
+ if (!equal.equal(diff.result, resultRef.current.data)) {
7815
+ resultRef.current = diffToResult(diff);
7816
+ clearTimeout(lastTimeout);
7817
+ lastTimeout = setTimeout(forceUpdate);
7818
+ }
7819
+ } }));
7820
+ return function () {
7821
+ unsubscribe();
7822
+ clearTimeout(lastTimeout);
7823
+ };
7824
+ }, [cache, diffOptions]), getSnapshot, getSnapshot);
7825
+ }
7826
+ function diffToResult(diff) {
7827
+ var result = {
7828
+ data: diff.result,
7829
+ complete: !!diff.complete,
7830
+ };
7831
+ if (diff.missing) {
7832
+ result.missing = mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
7833
+ }
7834
+ return result;
7835
+ }
7836
+
7833
7837
  var QUERY_REFERENCE_SYMBOL = Symbol();
7834
7838
  function wrapQueryRef(internalQueryRef) {
7835
7839
  var _a;