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

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 (55) hide show
  1. package/.changeset/pink-apricots-yawn.md +5 -0
  2. package/.changeset/pre.json +2 -1
  3. package/CHANGELOG.md +18 -0
  4. package/apollo-client.cjs +52 -46
  5. package/apollo-client.cjs.map +1 -1
  6. package/apollo-client.min.cjs +1 -1
  7. package/cache/cache.cjs +2 -2
  8. package/cache/cache.cjs.map +1 -1
  9. package/cache/cache.cjs.native.js +2 -2
  10. package/cache/inmemory/readFromStore.js +2 -2
  11. package/cache/inmemory/readFromStore.js.map +1 -1
  12. package/core/core.cjs +3 -3
  13. package/core/core.cjs.map +1 -1
  14. package/core/core.cjs.native.js +3 -3
  15. package/dev/dev.cjs +1 -1
  16. package/dev/dev.cjs.map +1 -1
  17. package/dev/dev.cjs.native.js +1 -1
  18. package/link/http/checkFetcher.d.ts +1 -1
  19. package/link/http/checkFetcher.js.map +1 -1
  20. package/link/http/http.cjs +0 -3
  21. package/link/http/http.cjs.map +1 -1
  22. package/link/http/http.cjs.native.js +0 -3
  23. package/link/http/parseAndCheckHttpResponse.js +0 -4
  24. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  25. package/link/http/selectHttpOptionsAndBody.d.ts +1 -1
  26. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  27. package/package.json +21 -21
  28. package/react/hooks/hooks.cjs +47 -38
  29. package/react/hooks/hooks.cjs.map +1 -1
  30. package/react/hooks/hooks.cjs.native.js +47 -38
  31. package/react/hooks/internal/index.d.ts +1 -0
  32. package/react/hooks/internal/index.js +1 -0
  33. package/react/hooks/internal/index.js.map +1 -1
  34. package/react/hooks/internal/useLazyRef.d.ts +3 -0
  35. package/react/hooks/internal/useLazyRef.js +10 -0
  36. package/react/hooks/internal/useLazyRef.js.map +1 -0
  37. package/react/hooks/useFragment.js +20 -17
  38. package/react/hooks/useFragment.js.map +1 -1
  39. package/react/parser/parser.cjs.map +1 -1
  40. package/testing/core/core.cjs +5 -3
  41. package/testing/core/core.cjs.map +1 -1
  42. package/testing/core/core.cjs.native.js +5 -3
  43. package/testing/core/mocking/mockLink.js +9 -3
  44. package/testing/core/mocking/mockLink.js.map +1 -1
  45. package/utilities/caching/getMemoryInternals.js +2 -2
  46. package/utilities/caching/getMemoryInternals.js.map +1 -1
  47. package/utilities/caching/sizes.d.ts +2 -2
  48. package/utilities/caching/sizes.js.map +1 -1
  49. package/utilities/globals/globals.cjs +1 -1
  50. package/utilities/globals/globals.cjs.map +1 -1
  51. package/utilities/globals/globals.cjs.native.js +1 -1
  52. package/utilities/subscriptions/relay/relay.cjs.map +1 -1
  53. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  54. package/utilities/utilities.cjs.map +1 -1
  55. package/version.js +1 -1
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": minor
3
+ ---
4
+
5
+ Increase the default memory limits for `executeSelectionSet` and `executeSelectionSetArray`.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "mode": "pre",
3
- "tag": "beta",
3
+ "tag": "rc",
4
4
  "initialVersions": {
5
5
  "@apollo/client": "3.8.3"
6
6
  },
@@ -18,6 +18,7 @@
18
18
  "hot-ducks-burn",
19
19
  "late-rabbits-protect",
20
20
  "mighty-coats-check",
21
+ "pink-apricots-yawn",
21
22
  "polite-avocados-warn",
22
23
  "quick-hats-marry",
23
24
  "rare-snakes-melt",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.9.0-rc.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#11495](https://github.com/apollographql/apollo-client/pull/11495) [`1190aa5`](https://github.com/apollographql/apollo-client/commit/1190aa59a106217f7192c1f81099adfa5e4365c1) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Increase the default memory limits for `executeSelectionSet` and `executeSelectionSetArray`.
8
+
9
+ ## 3.8.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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.
14
+
15
+ - [#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.
16
+
17
+ - [#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.
18
+
19
+ - [#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.
20
+
3
21
  ## 3.9.0-beta.1
4
22
 
5
23
  ### Minor Changes
package/apollo-client.cjs CHANGED
@@ -13,6 +13,7 @@ var optimism = require('optimism');
13
13
  var trie = require('@wry/trie');
14
14
  var graphqlTag = require('graphql-tag');
15
15
  var React = require('rehackt');
16
+ var React$1 = require('react');
16
17
 
17
18
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
18
19
 
@@ -30,8 +31,9 @@ function _interopNamespace(e) {
30
31
 
31
32
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
32
33
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
+ var React__namespace$1 = /*#__PURE__*/_interopNamespace(React$1);
33
35
 
34
- var version = "3.9.0-beta.1";
36
+ var version = "3.9.0-rc.0";
35
37
 
36
38
  function maybe(thunk) {
37
39
  try {
@@ -320,8 +322,8 @@ function getCurrentCacheSizes() {
320
322
  "cache.fragmentQueryDocuments": 1000 ,
321
323
  "removeTypenameFromVariables.getVariableDefinitions": 2000 ,
322
324
  "inMemoryCache.maybeBroadcastWatch": 5000 ,
323
- "inMemoryCache.executeSelectionSet": 10000 ,
324
- "inMemoryCache.executeSubSelectedArray": 5000 ,
325
+ "inMemoryCache.executeSelectionSet": 50000 ,
326
+ "inMemoryCache.executeSubSelectedArray": 10000 ,
325
327
  };
326
328
  return Object.fromEntries(Object.entries(defaults).map(function (_a) {
327
329
  var k = _a[0], v = _a[1];
@@ -2067,9 +2069,6 @@ function parseAndCheckHttpResponse(operations) {
2067
2069
  .text()
2068
2070
  .then(function (bodyText) { return parseJsonBody(response, bodyText); })
2069
2071
  .then(function (result) {
2070
- if (response.status >= 300) {
2071
- throwServerError(response, result, "Response not successful: Received status code ".concat(response.status));
2072
- }
2073
2072
  if (!Array.isArray(result) &&
2074
2073
  !hasOwnProperty$3.call(result, "data") &&
2075
2074
  !hasOwnProperty$3.call(result, "errors")) {
@@ -3202,7 +3201,7 @@ var StoreReader = (function () {
3202
3201
  }, {
3203
3202
  max: this.config.resultCacheMaxSize ||
3204
3203
  cacheSizes["inMemoryCache.executeSelectionSet"] ||
3205
- 10000 ,
3204
+ 50000 ,
3206
3205
  keyArgs: execSelectionSetKeyArgs,
3207
3206
  makeCacheKey: function (selectionSet, parent, context, canonizeResults) {
3208
3207
  if (supportsResultCaching(context.store)) {
@@ -3216,7 +3215,7 @@ var StoreReader = (function () {
3216
3215
  }, {
3217
3216
  max: this.config.resultCacheMaxSize ||
3218
3217
  cacheSizes["inMemoryCache.executeSubSelectedArray"] ||
3219
- 5000 ,
3218
+ 10000 ,
3220
3219
  makeCacheKey: function (_a) {
3221
3220
  var field = _a.field, array = _a.array, context = _a.context;
3222
3221
  if (supportsResultCaching(context.store)) {
@@ -7979,44 +7978,6 @@ function useReactiveVar(rv) {
7979
7978
  }, [rv]), rv, rv);
7980
7979
  }
7981
7980
 
7982
- function useFragment(options) {
7983
- var cache = useApolloClient().cache;
7984
- 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"]);
7985
- var diffOptions = tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
7986
- var resultRef = React__namespace.useRef();
7987
- var latestDiff = cache.diff(diffOptions);
7988
- var getSnapshot = function () {
7989
- var latestDiffToResult = diffToResult(latestDiff);
7990
- return (resultRef.current &&
7991
- equal.equal(resultRef.current.data, latestDiffToResult.data)) ?
7992
- resultRef.current
7993
- : (resultRef.current = latestDiffToResult);
7994
- };
7995
- return useSyncExternalStore(function (forceUpdate) {
7996
- var lastTimeout = 0;
7997
- var unsubcribe = cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
7998
- if (!equal.equal(diff, latestDiff)) {
7999
- resultRef.current = diffToResult((latestDiff = diff));
8000
- lastTimeout = setTimeout(forceUpdate);
8001
- }
8002
- } }));
8003
- return function () {
8004
- unsubcribe();
8005
- clearTimeout(lastTimeout);
8006
- };
8007
- }, getSnapshot, getSnapshot);
8008
- }
8009
- function diffToResult(diff) {
8010
- var result = {
8011
- data: diff.result,
8012
- complete: !!diff.complete,
8013
- };
8014
- if (diff.missing) {
8015
- result.missing = mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
8016
- }
8017
- return result;
8018
- }
8019
-
8020
7981
  function useDeepMemo(memoFn, deps) {
8021
7982
  var ref = React__namespace.useRef();
8022
7983
  if (!ref.current || !equal.equal(ref.current.deps, deps)) {
@@ -8037,6 +7998,15 @@ function useRenderGuard() {
8037
7998
  }, []);
8038
7999
  }
8039
8000
 
8001
+ var INIT = {};
8002
+ function useLazyRef(getInitialValue) {
8003
+ var ref = React__namespace$1.useRef(INIT);
8004
+ if (ref.current === INIT) {
8005
+ ref.current = getInitialValue();
8006
+ }
8007
+ return ref;
8008
+ }
8009
+
8040
8010
  var useKey = "use";
8041
8011
  var realHook = React__namespace[useKey];
8042
8012
  var __use = realHook ||
@@ -8052,6 +8022,42 @@ var __use = realHook ||
8052
8022
  }
8053
8023
  };
8054
8024
 
8025
+ function useFragment(options) {
8026
+ var cache = useApolloClient().cache;
8027
+ var diffOptions = useDeepMemo(function () {
8028
+ 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"]);
8029
+ return tslib.__assign(tslib.__assign({}, rest), { returnPartialData: true, id: typeof from === "string" ? from : cache.identify(from), query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic });
8030
+ }, [options]);
8031
+ var resultRef = useLazyRef(function () {
8032
+ return diffToResult(cache.diff(diffOptions));
8033
+ });
8034
+ var getSnapshot = React__namespace.useCallback(function () { return resultRef.current; }, []);
8035
+ return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
8036
+ var lastTimeout = 0;
8037
+ var unsubscribe = cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
8038
+ if (!equal.equal(diff.result, resultRef.current.data)) {
8039
+ resultRef.current = diffToResult(diff);
8040
+ clearTimeout(lastTimeout);
8041
+ lastTimeout = setTimeout(forceUpdate);
8042
+ }
8043
+ } }));
8044
+ return function () {
8045
+ unsubscribe();
8046
+ clearTimeout(lastTimeout);
8047
+ };
8048
+ }, [cache, diffOptions]), getSnapshot, getSnapshot);
8049
+ }
8050
+ function diffToResult(diff) {
8051
+ var result = {
8052
+ data: diff.result,
8053
+ complete: !!diff.complete,
8054
+ };
8055
+ if (diff.missing) {
8056
+ result.missing = mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
8057
+ }
8058
+ return result;
8059
+ }
8060
+
8055
8061
  var QUERY_REFERENCE_SYMBOL = Symbol();
8056
8062
  var PROMISE_SYMBOL = Symbol();
8057
8063
  function wrapQueryRef(internalQueryRef) {