@apollo/client 3.10.3 → 3.10.5

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 (102) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/apollo-client.cjs +166 -134
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/cache/cache.cjs +81 -8
  6. package/cache/cache.cjs.map +1 -1
  7. package/cache/cache.cjs.native.js +81 -8
  8. package/cache/core/cache.js +8 -4
  9. package/cache/core/cache.js.map +1 -1
  10. package/core/ApolloClient.js +2 -1
  11. package/core/ApolloClient.js.map +1 -1
  12. package/core/ObservableQuery.js +1 -1
  13. package/core/ObservableQuery.js.map +1 -1
  14. package/core/QueryInfo.js +7 -11
  15. package/core/QueryInfo.js.map +1 -1
  16. package/core/core.cjs +5 -7
  17. package/core/core.cjs.map +1 -1
  18. package/core/core.cjs.native.js +5 -7
  19. package/dev/dev.cjs +32 -27
  20. package/dev/dev.cjs.map +1 -1
  21. package/dev/dev.cjs.native.js +32 -27
  22. package/invariantErrorCodes.js +32 -26
  23. package/link/batch-http/batch-http.cjs +6 -5
  24. package/link/batch-http/batch-http.cjs.map +1 -1
  25. package/link/batch-http/batch-http.cjs.native.js +6 -5
  26. package/link/batch-http/batchHttpLink.js +15 -10
  27. package/link/batch-http/batchHttpLink.js.map +1 -1
  28. package/link/error/error.cjs +3 -2
  29. package/link/error/error.cjs.map +1 -1
  30. package/link/error/error.cjs.native.js +3 -2
  31. package/link/error/index.js +3 -2
  32. package/link/error/index.js.map +1 -1
  33. package/package.json +10 -6
  34. package/react/hooks/hooks.cjs +62 -34
  35. package/react/hooks/hooks.cjs.map +1 -1
  36. package/react/hooks/hooks.cjs.native.js +62 -34
  37. package/react/hooks/internal/useRenderGuard.js +37 -12
  38. package/react/hooks/internal/useRenderGuard.js.map +1 -1
  39. package/react/hooks/useBackgroundQuery.d.ts +10 -13
  40. package/react/hooks/useBackgroundQuery.js.map +1 -1
  41. package/react/hooks/useLazyQuery.js +7 -8
  42. package/react/hooks/useLazyQuery.js.map +1 -1
  43. package/react/hooks/useLoadableQuery.d.ts +3 -3
  44. package/react/hooks/useLoadableQuery.js +11 -3
  45. package/react/hooks/useLoadableQuery.js.map +1 -1
  46. package/react/hooks/useMutation.js +10 -7
  47. package/react/hooks/useMutation.js.map +1 -1
  48. package/react/hooks/useQuery.d.ts +2 -2
  49. package/react/hooks/useQuery.js +26 -12
  50. package/react/hooks/useQuery.js.map +1 -1
  51. package/react/hooks/useQueryRefHandlers.d.ts +3 -3
  52. package/react/hooks/useQueryRefHandlers.js +7 -2
  53. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  54. package/react/hooks/useReadQuery.d.ts +2 -2
  55. package/react/hooks/useReadQuery.js +7 -2
  56. package/react/hooks/useReadQuery.js.map +1 -1
  57. package/react/hooks/useSubscription.js +4 -0
  58. package/react/hooks/useSubscription.js.map +1 -1
  59. package/react/hooks/useSuspenseQuery.js +2 -2
  60. package/react/hooks/useSuspenseQuery.js.map +1 -1
  61. package/react/hooks/useSyncExternalStore.js +4 -0
  62. package/react/hooks/useSyncExternalStore.js.map +1 -1
  63. package/react/internal/cache/QueryReference.d.ts +68 -6
  64. package/react/internal/cache/QueryReference.js +4 -0
  65. package/react/internal/cache/QueryReference.js.map +1 -1
  66. package/react/internal/index.d.ts +2 -2
  67. package/react/internal/index.js +1 -1
  68. package/react/internal/index.js.map +1 -1
  69. package/react/internal/internal.cjs +92 -0
  70. package/react/internal/internal.cjs.map +1 -1
  71. package/react/internal/internal.cjs.native.js +92 -0
  72. package/react/parser/index.js +5 -5
  73. package/react/parser/parser.cjs +5 -5
  74. package/react/parser/parser.cjs.map +1 -1
  75. package/react/parser/parser.cjs.native.js +5 -5
  76. package/react/query-preloader/createQueryPreloader.d.ts +6 -6
  77. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  78. package/react/types/types.d.ts +1 -1
  79. package/react/types/types.js.map +1 -1
  80. package/testing/core/core.cjs +4 -4
  81. package/testing/core/core.cjs.map +1 -1
  82. package/testing/core/core.cjs.native.js +4 -4
  83. package/testing/core/mocking/mockLink.d.ts +8 -3
  84. package/testing/core/mocking/mockLink.js +5 -5
  85. package/testing/core/mocking/mockLink.js.map +1 -1
  86. package/testing/internal/profile/profile.js +6 -2
  87. package/testing/internal/profile/profile.js.map +1 -1
  88. package/testing/matchers/toBeDisposed.js +4 -13
  89. package/testing/matchers/toBeDisposed.js.map +1 -1
  90. package/utilities/globals/globals.cjs +1 -1
  91. package/utilities/globals/globals.cjs.map +1 -1
  92. package/utilities/globals/globals.cjs.native.js +1 -1
  93. package/utilities/graphql/DocumentTransform.js +1 -1
  94. package/utilities/graphql/directives.js +4 -4
  95. package/utilities/graphql/fragments.js +3 -3
  96. package/utilities/graphql/getFromAST.js +8 -8
  97. package/utilities/graphql/storeUtils.js +1 -1
  98. package/utilities/graphql/transform.js +2 -2
  99. package/utilities/utilities.cjs +19 -19
  100. package/utilities/utilities.cjs.map +1 -1
  101. package/utilities/utilities.cjs.native.js +19 -19
  102. package/version.js +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.10.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#11888](https://github.com/apollographql/apollo-client/pull/11888) [`7fb7939`](https://github.com/apollographql/apollo-client/commit/7fb7939edb7ca8f4273b75554f96ea9936731458) Thanks [@phryneas](https://github.com/phryneas)! - switch `useRenderGuard` to an approach not accessing React's internals
8
+
9
+ - [#11511](https://github.com/apollographql/apollo-client/pull/11511) [`6536369`](https://github.com/apollographql/apollo-client/commit/6536369cf213469d20d15b779c344268d70fecd5) Thanks [@phryneas](https://github.com/phryneas)! - `useLoadableQuery`: ensure that `loadQuery` is updated if the ApolloClient instance changes
10
+
11
+ - [#11860](https://github.com/apollographql/apollo-client/pull/11860) [`8740f19`](https://github.com/apollographql/apollo-client/commit/8740f198805a99e01136617c4055d611b92cc231) Thanks [@alessbell](https://github.com/alessbell)! - Fixes [#11849](https://github.com/apollographql/apollo-client/issues/11849) by reevaluating `window.fetch` each time `BatchHttpLink` uses it, if not configured via `options.fetch`. Takes the same approach as PR [#8603](https://github.com/apollographql/apollo-client/pull/8603) which fixed the same issue in `HttpLink`.
12
+
13
+ - [#11852](https://github.com/apollographql/apollo-client/pull/11852) [`d502a69`](https://github.com/apollographql/apollo-client/commit/d502a69654d8ffa31e09467da028304a934a9874) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where calling the `useMutation` `reset` function would point the hook to an outdated `client` reference.
14
+
15
+ - [#11329](https://github.com/apollographql/apollo-client/pull/11329) [`3d164ea`](https://github.com/apollographql/apollo-client/commit/3d164ea16c17d271f6fa9e5ad8f013623eec23a0) Thanks [@PaLy](https://github.com/PaLy)! - Fix graphQLErrors in Error Link if networkError.result is an empty string
16
+
17
+ - [#11852](https://github.com/apollographql/apollo-client/pull/11852) [`d502a69`](https://github.com/apollographql/apollo-client/commit/d502a69654d8ffa31e09467da028304a934a9874) Thanks [@phryneas](https://github.com/phryneas)! - Prevent writing to a ref in render in `useMutation`.
18
+ As a result, you might encounter problems in the future if you call the mutation's `execute` function during render. Please note that this was never supported behavior, and we strongly recommend against it.
19
+
20
+ - [#11848](https://github.com/apollographql/apollo-client/pull/11848) [`ad63924`](https://github.com/apollographql/apollo-client/commit/ad6392424ddbeb6f91b165c806251490e1cdd69e) Thanks [@phryneas](https://github.com/phryneas)! - Ensure covariant behavior: `MockedResponse<X,Y>` should be assignable to `MockedResponse`
21
+
22
+ - [#11851](https://github.com/apollographql/apollo-client/pull/11851) [`45c47be`](https://github.com/apollographql/apollo-client/commit/45c47be26d4e020cfcff359a5af19ccfc39b930e) Thanks [@phryneas](https://github.com/phryneas)! - Avoid usage of useRef in useInternalState to prevent ref access in render.
23
+
24
+ - [#11877](https://github.com/apollographql/apollo-client/pull/11877) [`634d91a`](https://github.com/apollographql/apollo-client/commit/634d91aeb10ab308b05d5ffb918678806046af09) Thanks [@phryneas](https://github.com/phryneas)! - Add missing name to tuple member (fix TS5084)
25
+
26
+ - [#11851](https://github.com/apollographql/apollo-client/pull/11851) [`45c47be`](https://github.com/apollographql/apollo-client/commit/45c47be26d4e020cfcff359a5af19ccfc39b930e) Thanks [@phryneas](https://github.com/phryneas)! - Fix a bug where `useLazyQuery` would not pick up a client change.
27
+
28
+ ## 3.10.4
29
+
30
+ ### Patch Changes
31
+
32
+ - [#11838](https://github.com/apollographql/apollo-client/pull/11838) [`8475346`](https://github.com/apollographql/apollo-client/commit/84753462af50d89c8693713990cccf432ff8267d) Thanks [@alex-kinokon](https://github.com/alex-kinokon)! - Don’t prompt for DevTools installation for browser extension page
33
+
34
+ - [#11839](https://github.com/apollographql/apollo-client/pull/11839) [`6481fe1`](https://github.com/apollographql/apollo-client/commit/6481fe1196cedee987781dcb45ebdc0cafb3998c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix a regression in [3.9.5](https://github.com/apollographql/apollo-client/releases/tag/v3.9.5) where a merge function that returned an incomplete result would not allow the client to refetch in order to fulfill the query.
35
+
36
+ - [#11844](https://github.com/apollographql/apollo-client/pull/11844) [`86984f2`](https://github.com/apollographql/apollo-client/commit/86984f24bd9076a6034acd59bbcb28a2ea1add93) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Honor the `@nonreactive` directive when using `cache.watchFragment` or the `useFragment` hook to avoid rerendering when using these directives.
37
+
38
+ - [#11824](https://github.com/apollographql/apollo-client/pull/11824) [`47ad806`](https://github.com/apollographql/apollo-client/commit/47ad806c7b0c55f1e05dbf276ca87a354ac389e5) Thanks [@phryneas](https://github.com/phryneas)! - Create branded `QueryRef` type without exposed properties.
39
+
40
+ This change deprecates `QueryReference` in favor of a `QueryRef` type that doesn't expose any properties.
41
+ This change also updates `preloadQuery` to return a new `PreloadedQueryRef` type, which exposes the `toPromise` function as it does today. This means that query refs produced by `useBackgroundQuery` and `useLoadableQuery` now return `QueryRef` types that do not have access to a `toPromise` function, which was never meant to be used in combination with these hooks.
42
+
43
+ While we tend to avoid any types of breaking changes in patch releases as this, this change was necessary to support an upcoming version of the React Server Component integration, which needed to omit the `toPromise` function that would otherwise have broken at runtime.
44
+ Note that this is a TypeScript-only change. At runtime, `toPromise` is still present on all queryRefs currently created by this package - but we strongly want to discourage you from accessing it in all cases except for the `PreloadedQueryRef` use case.
45
+
46
+ Migration is as simple as replacing all references to `QueryReference` with `QueryRef`, so it should be possible to do this with a search & replace in most code bases:
47
+
48
+ ```diff
49
+ -import { QueryReference } from '@apollo/client'
50
+ +import { QueryRef } from '@apollo/client'
51
+
52
+ - function Component({ queryRef }: { queryRef: QueryReference<TData> }) {
53
+ + function Component({ queryRef }: { queryRef: QueryRef<TData> }) {
54
+ // ...
55
+ }
56
+ ```
57
+
58
+ - [#11845](https://github.com/apollographql/apollo-client/pull/11845) [`4c5c820`](https://github.com/apollographql/apollo-client/commit/4c5c820b6172f6a2455bcdd974109513e0e2a39e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Remove `@nonreactive` directives from queries passed to `MockLink` to ensure they are properly matched.
59
+
60
+ - [#11837](https://github.com/apollographql/apollo-client/pull/11837) [`dff15b1`](https://github.com/apollographql/apollo-client/commit/dff15b1b03ebac9cae508c69bf607a29d0f6eccb) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix an issue where a polled query created in React strict mode may not stop polling after the component unmounts while using the `cache-and-network` fetch policy.
61
+
3
62
  ## 3.10.3
4
63
 
5
64
  ### 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.3";
34
+ var version = "3.10.5";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -137,7 +137,7 @@ function shouldInclude(_a, variables) {
137
137
  if (ifArgument.value.kind === "Variable") {
138
138
  evaledValue =
139
139
  variables && variables[ifArgument.value.name.value];
140
- invariant(evaledValue !== void 0, 67, directive.name.value);
140
+ invariant(evaledValue !== void 0, 68, directive.name.value);
141
141
  }
142
142
  else {
143
143
  evaledValue = ifArgument.value.value;
@@ -172,12 +172,12 @@ function getInclusionDirectives(directives) {
172
172
  return;
173
173
  var directiveArguments = directive.arguments;
174
174
  var directiveName = directive.name.value;
175
- invariant(directiveArguments && directiveArguments.length === 1, 68, directiveName);
175
+ invariant(directiveArguments && directiveArguments.length === 1, 69, directiveName);
176
176
  var ifArgument = directiveArguments[0];
177
- invariant(ifArgument.name && ifArgument.name.value === "if", 69, directiveName);
177
+ invariant(ifArgument.name && ifArgument.name.value === "if", 70, directiveName);
178
178
  var ifValue = ifArgument.value;
179
179
  invariant(ifValue &&
180
- (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 70, directiveName);
180
+ (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 71, directiveName);
181
181
  result.push({ directive: directive, ifArgument: ifArgument });
182
182
  });
183
183
  }
@@ -204,7 +204,7 @@ function getFragmentQueryDocument(document, fragmentName) {
204
204
  document.definitions.forEach(function (definition) {
205
205
  if (definition.kind === "OperationDefinition") {
206
206
  throw newInvariantError(
207
- 71,
207
+ 72,
208
208
  definition.operation,
209
209
  definition.name ? " named '".concat(definition.name.value, "'") : ""
210
210
  );
@@ -214,7 +214,7 @@ function getFragmentQueryDocument(document, fragmentName) {
214
214
  }
215
215
  });
216
216
  if (typeof actualFragmentName === "undefined") {
217
- invariant(fragments.length === 1, 72, fragments.length);
217
+ invariant(fragments.length === 1, 73, fragments.length);
218
218
  actualFragmentName = fragments[0].name.value;
219
219
  }
220
220
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -255,7 +255,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
255
255
  return fragmentMap(fragmentName);
256
256
  }
257
257
  var fragment = fragmentMap && fragmentMap[fragmentName];
258
- invariant(fragment, 73, fragmentName);
258
+ invariant(fragment, 74, fragmentName);
259
259
  return fragment || null;
260
260
  }
261
261
  default:
@@ -506,7 +506,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
506
506
  argObj[name.value] = null;
507
507
  }
508
508
  else {
509
- throw newInvariantError(82, name.value, value.kind);
509
+ throw newInvariantError(83, name.value, value.kind);
510
510
  }
511
511
  }
512
512
  function storeKeyNameFromField(field, variables) {
@@ -640,16 +640,16 @@ function isInlineFragment(selection) {
640
640
  }
641
641
 
642
642
  function checkDocument(doc) {
643
- invariant(doc && doc.kind === "Document", 74);
643
+ invariant(doc && doc.kind === "Document", 75);
644
644
  var operations = doc.definitions
645
645
  .filter(function (d) { return d.kind !== "FragmentDefinition"; })
646
646
  .map(function (definition) {
647
647
  if (definition.kind !== "OperationDefinition") {
648
- throw newInvariantError(75, definition.kind);
648
+ throw newInvariantError(76, definition.kind);
649
649
  }
650
650
  return definition;
651
651
  });
652
- invariant(operations.length <= 1, 76, operations.length);
652
+ invariant(operations.length <= 1, 77, operations.length);
653
653
  return doc;
654
654
  }
655
655
  function getOperationDefinition(doc) {
@@ -672,14 +672,14 @@ function getFragmentDefinitions(doc) {
672
672
  }
673
673
  function getQueryDefinition(doc) {
674
674
  var queryDef = getOperationDefinition(doc);
675
- invariant(queryDef && queryDef.operation === "query", 77);
675
+ invariant(queryDef && queryDef.operation === "query", 78);
676
676
  return queryDef;
677
677
  }
678
678
  function getFragmentDefinition(doc) {
679
- invariant(doc.kind === "Document", 78);
680
- invariant(doc.definitions.length <= 1, 79);
679
+ invariant(doc.kind === "Document", 79);
680
+ invariant(doc.definitions.length <= 1, 80);
681
681
  var fragmentDef = doc.definitions[0];
682
- invariant(fragmentDef.kind === "FragmentDefinition", 80);
682
+ invariant(fragmentDef.kind === "FragmentDefinition", 81);
683
683
  return fragmentDef;
684
684
  }
685
685
  function getMainDefinition(queryDoc) {
@@ -702,7 +702,7 @@ function getMainDefinition(queryDoc) {
702
702
  if (fragmentDefinition) {
703
703
  return fragmentDefinition;
704
704
  }
705
- throw newInvariantError(81);
705
+ throw newInvariantError(82);
706
706
  }
707
707
  function getDefaultValues(definition) {
708
708
  var defaultValues = Object.create(null);
@@ -753,7 +753,7 @@ var DocumentTransform = (function () {
753
753
  makeCacheKey: function (document) {
754
754
  var cacheKeys = _this.getCacheKey(document);
755
755
  if (cacheKeys) {
756
- invariant(Array.isArray(cacheKeys), 66);
756
+ invariant(Array.isArray(cacheKeys), 67);
757
757
  return stableCacheKeys_1.lookupArray(cacheKeys);
758
758
  }
759
759
  },
@@ -883,7 +883,7 @@ function removeDirectivesFromDocument(directives, doc) {
883
883
  return getInUseByFragmentName(ancestor.name.value);
884
884
  }
885
885
  }
886
- globalThis.__DEV__ !== false && invariant.error(83);
886
+ globalThis.__DEV__ !== false && invariant.error(84);
887
887
  return null;
888
888
  };
889
889
  var operationCount = 0;
@@ -2381,6 +2381,72 @@ var HttpLink = (function (_super) {
2381
2381
  return HttpLink;
2382
2382
  }(ApolloLink));
2383
2383
 
2384
+ function equalByQuery(query, _a, _b, variables) {
2385
+ var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
2386
+ var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
2387
+ return (equal__default(aRest, bRest) &&
2388
+ equalBySelectionSet(getMainDefinition(query).selectionSet, aData, bData, {
2389
+ fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
2390
+ variables: variables,
2391
+ }));
2392
+ }
2393
+ function equalBySelectionSet(selectionSet, aResult, bResult, context) {
2394
+ if (aResult === bResult) {
2395
+ return true;
2396
+ }
2397
+ var seenSelections = new Set();
2398
+ return selectionSet.selections.every(function (selection) {
2399
+ if (seenSelections.has(selection))
2400
+ return true;
2401
+ seenSelections.add(selection);
2402
+ if (!shouldInclude(selection, context.variables))
2403
+ return true;
2404
+ if (selectionHasNonreactiveDirective(selection))
2405
+ return true;
2406
+ if (isField(selection)) {
2407
+ var resultKey = resultKeyNameFromField(selection);
2408
+ var aResultChild = aResult && aResult[resultKey];
2409
+ var bResultChild = bResult && bResult[resultKey];
2410
+ var childSelectionSet = selection.selectionSet;
2411
+ if (!childSelectionSet) {
2412
+ return equal__default(aResultChild, bResultChild);
2413
+ }
2414
+ var aChildIsArray = Array.isArray(aResultChild);
2415
+ var bChildIsArray = Array.isArray(bResultChild);
2416
+ if (aChildIsArray !== bChildIsArray)
2417
+ return false;
2418
+ if (aChildIsArray && bChildIsArray) {
2419
+ var length_1 = aResultChild.length;
2420
+ if (bResultChild.length !== length_1) {
2421
+ return false;
2422
+ }
2423
+ for (var i = 0; i < length_1; ++i) {
2424
+ if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
2425
+ return false;
2426
+ }
2427
+ }
2428
+ return true;
2429
+ }
2430
+ return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
2431
+ }
2432
+ else {
2433
+ var fragment = getFragmentFromSelection(selection, context.fragmentMap);
2434
+ if (fragment) {
2435
+ if (selectionHasNonreactiveDirective(fragment))
2436
+ return true;
2437
+ return equalBySelectionSet(fragment.selectionSet,
2438
+ aResult, bResult, context);
2439
+ }
2440
+ }
2441
+ });
2442
+ }
2443
+ function selectionHasNonreactiveDirective(selection) {
2444
+ return (!!selection.directives && selection.directives.some(directiveIsNonreactive));
2445
+ }
2446
+ function directiveIsNonreactive(dir) {
2447
+ return dir.name.value === "nonreactive";
2448
+ }
2449
+
2384
2450
  var ApolloCache = (function () {
2385
2451
  function ApolloCache() {
2386
2452
  this.assumeImmutableResults = false;
@@ -2424,16 +2490,19 @@ var ApolloCache = (function () {
2424
2490
  ApolloCache.prototype.watchFragment = function (options) {
2425
2491
  var _this = this;
2426
2492
  var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a;
2493
+ var query = this.getFragmentDoc(fragment, fragmentName);
2427
2494
  var diffOptions = {
2428
2495
  returnPartialData: true,
2429
2496
  id: typeof from === "string" ? from : this.identify(from),
2430
- query: this.getFragmentDoc(fragment, fragmentName),
2497
+ query: query,
2431
2498
  optimistic: optimistic,
2432
2499
  };
2433
2500
  var latestDiff;
2434
2501
  return new zenObservableTs.Observable(function (observer) {
2435
- return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, query: _this.getFragmentDoc(fragment, fragmentName), callback: function (diff) {
2436
- if (equal.equal(diff, latestDiff)) {
2502
+ return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
2503
+ if (
2504
+ latestDiff &&
2505
+ equalByQuery(query, { data: latestDiff === null || latestDiff === void 0 ? void 0 : latestDiff.result }, { data: diff.result })) {
2437
2506
  return;
2438
2507
  }
2439
2508
  var result = {
@@ -4805,72 +4874,6 @@ function isNetworkRequestSettled(networkStatus) {
4805
4874
  return networkStatus === 7 || networkStatus === 8;
4806
4875
  }
4807
4876
 
4808
- function equalByQuery(query, _a, _b, variables) {
4809
- var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
4810
- var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
4811
- return (equal__default(aRest, bRest) &&
4812
- equalBySelectionSet(getMainDefinition(query).selectionSet, aData, bData, {
4813
- fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
4814
- variables: variables,
4815
- }));
4816
- }
4817
- function equalBySelectionSet(selectionSet, aResult, bResult, context) {
4818
- if (aResult === bResult) {
4819
- return true;
4820
- }
4821
- var seenSelections = new Set();
4822
- return selectionSet.selections.every(function (selection) {
4823
- if (seenSelections.has(selection))
4824
- return true;
4825
- seenSelections.add(selection);
4826
- if (!shouldInclude(selection, context.variables))
4827
- return true;
4828
- if (selectionHasNonreactiveDirective(selection))
4829
- return true;
4830
- if (isField(selection)) {
4831
- var resultKey = resultKeyNameFromField(selection);
4832
- var aResultChild = aResult && aResult[resultKey];
4833
- var bResultChild = bResult && bResult[resultKey];
4834
- var childSelectionSet = selection.selectionSet;
4835
- if (!childSelectionSet) {
4836
- return equal__default(aResultChild, bResultChild);
4837
- }
4838
- var aChildIsArray = Array.isArray(aResultChild);
4839
- var bChildIsArray = Array.isArray(bResultChild);
4840
- if (aChildIsArray !== bChildIsArray)
4841
- return false;
4842
- if (aChildIsArray && bChildIsArray) {
4843
- var length_1 = aResultChild.length;
4844
- if (bResultChild.length !== length_1) {
4845
- return false;
4846
- }
4847
- for (var i = 0; i < length_1; ++i) {
4848
- if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
4849
- return false;
4850
- }
4851
- }
4852
- return true;
4853
- }
4854
- return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
4855
- }
4856
- else {
4857
- var fragment = getFragmentFromSelection(selection, context.fragmentMap);
4858
- if (fragment) {
4859
- if (selectionHasNonreactiveDirective(fragment))
4860
- return true;
4861
- return equalBySelectionSet(fragment.selectionSet,
4862
- aResult, bResult, context);
4863
- }
4864
- }
4865
- });
4866
- }
4867
- function selectionHasNonreactiveDirective(selection) {
4868
- return (!!selection.directives && selection.directives.some(directiveIsNonreactive));
4869
- }
4870
- function directiveIsNonreactive(dir) {
4871
- return dir.name.value === "nonreactive";
4872
- }
4873
-
4874
4877
  var assign = Object.assign, hasOwnProperty$2 = Object.hasOwnProperty;
4875
4878
  var ObservableQuery = (function (_super) {
4876
4879
  tslib.__extends(ObservableQuery, _super);
@@ -5242,7 +5245,7 @@ var ObservableQuery = (function (_super) {
5242
5245
  return;
5243
5246
  }
5244
5247
  var _a = this, pollingInfo = _a.pollingInfo, pollInterval = _a.options.pollInterval;
5245
- if (!pollInterval) {
5248
+ if (!pollInterval || !this.hasObservers()) {
5246
5249
  if (pollingInfo) {
5247
5250
  clearTimeout(pollingInfo.timeout);
5248
5251
  delete this.pollingInfo;
@@ -5857,10 +5860,7 @@ var QueryInfo = (function () {
5857
5860
  var _this = this;
5858
5861
  var _a;
5859
5862
  var oldDiff = this.lastDiff && this.lastDiff.diff;
5860
- if (diff &&
5861
- !diff.complete &&
5862
- !((_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.options.returnPartialData) &&
5863
- !(oldDiff && oldDiff.complete)) {
5863
+ if (diff && !diff.complete && ((_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.getLastError())) {
5864
5864
  return;
5865
5865
  }
5866
5866
  this.updateLastDiff(diff);
@@ -7029,7 +7029,8 @@ var ApolloClient = (function () {
7029
7029
  if (typeof window !== "undefined" &&
7030
7030
  window.document &&
7031
7031
  window.top === window.self &&
7032
- !window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__) {
7032
+ !window.__APOLLO_DEVTOOLS_GLOBAL_HOOK__ &&
7033
+ /^(https?|file):$/.test(window.location.protocol)) {
7033
7034
  var nav = window.navigator;
7034
7035
  var ua = nav && nav.userAgent;
7035
7036
  var url = void 0;
@@ -7337,7 +7338,7 @@ function parser(document) {
7337
7338
  if (cached)
7338
7339
  return cached;
7339
7340
  var variables, type, name;
7340
- invariant(!!document && !!document.kind, 59, document);
7341
+ invariant(!!document && !!document.kind, 60, document);
7341
7342
  var fragments = [];
7342
7343
  var queries = [];
7343
7344
  var mutations = [];
@@ -7365,10 +7366,10 @@ function parser(document) {
7365
7366
  invariant(!fragments.length ||
7366
7367
  queries.length ||
7367
7368
  mutations.length ||
7368
- subscriptions.length, 60);
7369
+ subscriptions.length, 61);
7369
7370
  invariant(
7370
7371
  queries.length + mutations.length + subscriptions.length <= 1,
7371
- 61,
7372
+ 62,
7372
7373
  document,
7373
7374
  queries.length,
7374
7375
  subscriptions.length,
@@ -7380,7 +7381,7 @@ function parser(document) {
7380
7381
  var definitions = queries.length ? queries
7381
7382
  : mutations.length ? mutations
7382
7383
  : subscriptions;
7383
- invariant(definitions.length === 1, 62, document, definitions.length);
7384
+ invariant(definitions.length === 1, 63, document, definitions.length);
7384
7385
  var definition = definitions[0];
7385
7386
  variables = definition.variableDefinitions || [];
7386
7387
  if (definition.name && definition.name.kind === "Name") {
@@ -7405,7 +7406,7 @@ function verifyDocumentType(document, type) {
7405
7406
  var usedOperationName = operationName(operation.type);
7406
7407
  invariant(
7407
7408
  operation.type === type,
7408
- 63,
7409
+ 64,
7409
7410
  requiredOperationName,
7410
7411
  requiredOperationName,
7411
7412
  usedOperationName
@@ -7420,15 +7421,26 @@ function useDeepMemo(memoFn, deps) {
7420
7421
  return ref.current.value;
7421
7422
  }
7422
7423
 
7423
- function getRenderDispatcher() {
7424
- var _a, _b;
7425
- return (_b = (_a = React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || _a === void 0 ? void 0 : _a.ReactCurrentDispatcher) === null || _b === void 0 ? void 0 : _b.current;
7426
- }
7427
- var RenderDispatcher = null;
7424
+ var Ctx;
7425
+ function noop() { }
7428
7426
  function useRenderGuard() {
7429
- RenderDispatcher = getRenderDispatcher();
7430
- return React__namespace.useCallback(function () {
7431
- return (RenderDispatcher != null && RenderDispatcher === getRenderDispatcher());
7427
+ if (!Ctx) {
7428
+ Ctx = React__namespace.createContext(null);
7429
+ }
7430
+ return React__namespace.useCallback(
7431
+ function () {
7432
+ var orig = console.error;
7433
+ try {
7434
+ console.error = noop;
7435
+ React__namespace["useContext" ](Ctx);
7436
+ return true;
7437
+ }
7438
+ catch (e) {
7439
+ return false;
7440
+ }
7441
+ finally {
7442
+ console.error = orig;
7443
+ }
7432
7444
  }, []);
7433
7445
  }
7434
7446
 
@@ -7473,14 +7485,16 @@ function _useQuery(query, options) {
7473
7485
  return useInternalState(useApolloClient(options.client), query).useQuery(options);
7474
7486
  }
7475
7487
  function useInternalState(client, query) {
7476
- var stateRef = React__namespace.useRef();
7477
- if (!stateRef.current ||
7478
- client !== stateRef.current.client ||
7479
- query !== stateRef.current.query) {
7480
- stateRef.current = new InternalState(client, query, stateRef.current);
7481
- }
7482
- var state = stateRef.current;
7483
- state.forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
7488
+ var forceUpdateState = React__namespace.useReducer(function (tick) { return tick + 1; }, 0)[1];
7489
+ function createInternalState(previous) {
7490
+ return Object.assign(new InternalState(client, query, previous), {
7491
+ forceUpdateState: forceUpdateState,
7492
+ });
7493
+ }
7494
+ var _a = React__namespace.useState(createInternalState), state = _a[0], updateState = _a[1];
7495
+ if (client !== state.client || query !== state.query) {
7496
+ updateState((state = createInternalState(state)));
7497
+ }
7484
7498
  return state;
7485
7499
  }
7486
7500
  var InternalState = (function () {
@@ -7543,7 +7557,8 @@ var InternalState = (function () {
7543
7557
  this.renderPromises = React__namespace.useContext(getApolloContext()).renderPromises;
7544
7558
  this.useOptions(options);
7545
7559
  var obsQuery = this.useObservableQuery();
7546
- var result = useSyncExternalStore(React__namespace.useCallback(function (handleStoreChange) {
7560
+ var result = useSyncExternalStore(
7561
+ React__namespace.useCallback(function (handleStoreChange) {
7547
7562
  if (_this.renderPromises) {
7548
7563
  return function () { };
7549
7564
  }
@@ -7778,17 +7793,15 @@ function useLazyQuery(query, options) {
7778
7793
  var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
7779
7794
  var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
7780
7795
  internalState.getDefaultFetchPolicy();
7781
- var result = Object.assign(useQueryResult, {
7782
- called: !!execOptionsRef.current,
7783
- });
7796
+ var forceUpdateState = internalState.forceUpdateState, obsQueryFields = internalState.obsQueryFields;
7784
7797
  var eagerMethods = React__namespace.useMemo(function () {
7785
7798
  var eagerMethods = {};
7786
7799
  var _loop_1 = function (key) {
7787
- var method = result[key];
7800
+ var method = obsQueryFields[key];
7788
7801
  eagerMethods[key] = function () {
7789
7802
  if (!execOptionsRef.current) {
7790
7803
  execOptionsRef.current = Object.create(null);
7791
- internalState.forceUpdateState();
7804
+ forceUpdateState();
7792
7805
  }
7793
7806
  return method.apply(this, arguments);
7794
7807
  };
@@ -7798,8 +7811,9 @@ function useLazyQuery(query, options) {
7798
7811
  _loop_1(key);
7799
7812
  }
7800
7813
  return eagerMethods;
7801
- }, []);
7802
- Object.assign(result, eagerMethods);
7814
+ }, [forceUpdateState, obsQueryFields]);
7815
+ var called = !!execOptionsRef.current;
7816
+ var result = React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign(tslib.__assign({}, useQueryResult), eagerMethods), { called: called })); }, [useQueryResult, eagerMethods, called]);
7803
7817
  var execute = React__namespace.useCallback(function (executeOptions) {
7804
7818
  execOptionsRef.current =
7805
7819
  executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
@@ -7811,7 +7825,7 @@ function useLazyQuery(query, options) {
7811
7825
  .then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
7812
7826
  promise.catch(function () { });
7813
7827
  return promise;
7814
- }, []);
7828
+ }, [eagerMethods, initialFetchPolicy, internalState]);
7815
7829
  return [execute, result];
7816
7830
  }
7817
7831
 
@@ -7831,9 +7845,9 @@ function useMutation(mutation, options) {
7831
7845
  mutation: mutation,
7832
7846
  options: options,
7833
7847
  });
7834
- {
7848
+ React__namespace.useLayoutEffect(function () {
7835
7849
  Object.assign(ref.current, { client: client, options: options, mutation: mutation });
7836
- }
7850
+ });
7837
7851
  var execute = React__namespace.useCallback(function (executeOptions) {
7838
7852
  if (executeOptions === void 0) { executeOptions = {}; }
7839
7853
  var _a = ref.current, options = _a.options, mutation = _a.mutation;
@@ -7907,15 +7921,20 @@ function useMutation(mutation, options) {
7907
7921
  }, []);
7908
7922
  var reset = React__namespace.useCallback(function () {
7909
7923
  if (ref.current.isMounted) {
7910
- var result_3 = { called: false, loading: false, client: client };
7924
+ var result_3 = {
7925
+ called: false,
7926
+ loading: false,
7927
+ client: ref.current.client,
7928
+ };
7911
7929
  Object.assign(ref.current, { mutationId: 0, result: result_3 });
7912
7930
  setResult(result_3);
7913
7931
  }
7914
7932
  }, []);
7915
7933
  React__namespace.useEffect(function () {
7916
- ref.current.isMounted = true;
7934
+ var current = ref.current;
7935
+ current.isMounted = true;
7917
7936
  return function () {
7918
- ref.current.isMounted = false;
7937
+ current.isMounted = false;
7919
7938
  };
7920
7939
  }, []);
7921
7940
  return [execute, tslib.__assign({ reset: reset }, result)];
@@ -8133,6 +8152,9 @@ function wrapQueryRef(internalQueryRef) {
8133
8152
  _a);
8134
8153
  return ref;
8135
8154
  }
8155
+ function assertWrappedQueryRef(queryRef) {
8156
+ invariant(!queryRef || QUERY_REFERENCE_SYMBOL in queryRef, 59);
8157
+ }
8136
8158
  function getWrappedPromise(queryRef) {
8137
8159
  var internalQueryRef = unwrapQueryRef(queryRef);
8138
8160
  return internalQueryRef.promise.status === "fulfilled" ?
@@ -8465,11 +8487,11 @@ function _useSuspenseQuery(query, options) {
8465
8487
  };
8466
8488
  }, [queryRef.result]);
8467
8489
  var result = fetchPolicy === "standby" ? skipResult : __use(promise);
8468
- var fetchMore = React__namespace.useCallback((function (options) {
8490
+ var fetchMore = React__namespace.useCallback(function (options) {
8469
8491
  var promise = queryRef.fetchMore(options);
8470
8492
  setPromise([queryRef.key, queryRef.promise]);
8471
8493
  return promise;
8472
- }), [queryRef]);
8494
+ }, [queryRef]);
8473
8495
  var refetch = React__namespace.useCallback(function (variables) {
8474
8496
  var promise = queryRef.refetch(variables);
8475
8497
  setPromise([queryRef.key, queryRef.promise]);
@@ -8594,6 +8616,7 @@ function useLoadableQuery(query, options) {
8594
8616
  var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
8595
8617
  var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
8596
8618
  var _b = React__namespace.useState(null), queryRef = _b[0], setQueryRef = _b[1];
8619
+ assertWrappedQueryRef(queryRef);
8597
8620
  var internalQueryRef = queryRef && unwrapQueryRef(queryRef);
8598
8621
  if (queryRef && (internalQueryRef === null || internalQueryRef === void 0 ? void 0 : internalQueryRef.didChangeOptions(watchQueryOptions))) {
8599
8622
  var promise = internalQueryRef.applyOptions(watchQueryOptions);
@@ -8631,10 +8654,17 @@ function useLoadableQuery(query, options) {
8631
8654
  return client.watchQuery(tslib.__assign(tslib.__assign({}, watchQueryOptions), { variables: variables }));
8632
8655
  });
8633
8656
  setQueryRef(wrapQueryRef(queryRef));
8634
- }, [query, queryKey, suspenseCache, watchQueryOptions, calledDuringRender]);
8657
+ }, [
8658
+ query,
8659
+ queryKey,
8660
+ suspenseCache,
8661
+ watchQueryOptions,
8662
+ calledDuringRender,
8663
+ client,
8664
+ ]);
8635
8665
  var reset = React__namespace.useCallback(function () {
8636
8666
  setQueryRef(null);
8637
- }, [queryRef]);
8667
+ }, []);
8638
8668
  return [loadQuery, queryRef, { fetchMore: fetchMore, refetch: refetch, reset: reset }];
8639
8669
  }
8640
8670
 
@@ -8645,6 +8675,7 @@ function useQueryRefHandlers(queryRef) {
8645
8675
  : useApolloClient())(queryRef);
8646
8676
  }
8647
8677
  function _useQueryRefHandlers(queryRef) {
8678
+ assertWrappedQueryRef(queryRef);
8648
8679
  var _a = React__namespace.useState(queryRef), previousQueryRef = _a[0], setPreviousQueryRef = _a[1];
8649
8680
  var _b = React__namespace.useState(queryRef), wrappedQueryRef = _b[0], setWrappedQueryRef = _b[1];
8650
8681
  var internalQueryRef = unwrapQueryRef(queryRef);
@@ -8675,6 +8706,7 @@ function useReadQuery(queryRef) {
8675
8706
  : useApolloClient())(queryRef);
8676
8707
  }
8677
8708
  function _useReadQuery(queryRef) {
8709
+ assertWrappedQueryRef(queryRef);
8678
8710
  var internalQueryRef = React__namespace.useMemo(function () { return unwrapQueryRef(queryRef); }, [queryRef]);
8679
8711
  var getPromise = React__namespace.useCallback(function () { return getWrappedPromise(queryRef); }, [queryRef]);
8680
8712
  if (internalQueryRef.disposed) {
@@ -8687,7 +8719,7 @@ function _useReadQuery(queryRef) {
8687
8719
  updateWrappedQueryRef(queryRef, promise);
8688
8720
  forceUpdate();
8689
8721
  });
8690
- }, [internalQueryRef]), getPromise, getPromise);
8722
+ }, [internalQueryRef, queryRef]), getPromise, getPromise);
8691
8723
  var result = __use(promise);
8692
8724
  return React__namespace.useMemo(function () {
8693
8725
  return {