@apollo/client 3.12.0-alpha.0 → 3.12.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 (137) hide show
  1. package/.changeset/cold-apes-bow.md +5 -0
  2. package/.changeset/early-bobcats-eat.md +5 -0
  3. package/.changeset/flat-beans-knock.md +15 -0
  4. package/.changeset/kind-toys-tie.md +5 -0
  5. package/.changeset/nervous-owls-hear.md +5 -0
  6. package/.changeset/pre.json +7 -2
  7. package/CHANGELOG.md +34 -0
  8. package/apollo-client.cjs +133 -77
  9. package/apollo-client.cjs.map +1 -1
  10. package/apollo-client.min.cjs +1 -1
  11. package/cache/cache.cjs +30 -20
  12. package/cache/cache.cjs.map +1 -1
  13. package/cache/cache.cjs.native.js +30 -20
  14. package/cache/inmemory/policies.js +12 -9
  15. package/cache/inmemory/policies.js.map +1 -1
  16. package/config/jest/setup.js +5 -0
  17. package/config/jest/setup.js.map +1 -1
  18. package/core/ApolloClient.js +7 -3
  19. package/core/ApolloClient.js.map +1 -1
  20. package/core/ObservableQuery.js +2 -0
  21. package/core/ObservableQuery.js.map +1 -1
  22. package/core/QueryManager.d.ts +4 -1
  23. package/core/QueryManager.js +26 -2
  24. package/core/QueryManager.js.map +1 -1
  25. package/core/core.cjs +57 -20
  26. package/core/core.cjs.map +1 -1
  27. package/core/core.cjs.native.js +57 -20
  28. package/core/masking.d.ts +6 -0
  29. package/core/masking.js +33 -15
  30. package/core/masking.js.map +1 -1
  31. package/dev/dev.cjs +66 -62
  32. package/dev/dev.cjs.map +1 -1
  33. package/dev/dev.cjs.native.js +66 -62
  34. package/invariantErrorCodes.js +66 -61
  35. package/link/core/ApolloLink.js +2 -2
  36. package/link/core/core.cjs +2 -2
  37. package/link/core/core.cjs.map +1 -1
  38. package/link/core/core.cjs.native.js +2 -2
  39. package/link/http/checkFetcher.js +1 -1
  40. package/link/http/createHttpLink.js +1 -1
  41. package/link/http/http.cjs +3 -3
  42. package/link/http/http.cjs.map +1 -1
  43. package/link/http/http.cjs.native.js +3 -3
  44. package/link/http/serializeFetchParameter.js +1 -1
  45. package/link/persisted-queries/index.js +2 -2
  46. package/link/persisted-queries/index.js.map +1 -1
  47. package/link/persisted-queries/persisted-queries.cjs +2 -2
  48. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  49. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  50. package/link/utils/toPromise.js +1 -1
  51. package/link/utils/utils.cjs +2 -2
  52. package/link/utils/utils.cjs.map +1 -1
  53. package/link/utils/utils.cjs.native.js +2 -2
  54. package/link/utils/validateOperation.js +1 -1
  55. package/masking/types.d.ts +2 -2
  56. package/masking/types.js.map +1 -1
  57. package/package.json +4 -3
  58. package/react/context/ApolloConsumer.js +1 -1
  59. package/react/context/ApolloContext.js +1 -1
  60. package/react/context/ApolloProvider.js +1 -1
  61. package/react/context/context.cjs +3 -3
  62. package/react/context/context.cjs.map +1 -1
  63. package/react/context/context.cjs.native.js +3 -3
  64. package/react/hoc/hoc-utils.js +1 -1
  65. package/react/hoc/hoc.cjs +2 -2
  66. package/react/hoc/hoc.cjs.map +1 -1
  67. package/react/hoc/hoc.cjs.native.js +2 -2
  68. package/react/hoc/withApollo.js +1 -1
  69. package/react/hooks/hooks.cjs +9 -9
  70. package/react/hooks/hooks.cjs.map +1 -1
  71. package/react/hooks/hooks.cjs.native.js +9 -9
  72. package/react/hooks/useApolloClient.js +1 -1
  73. package/react/hooks/useLoadableQuery.js +2 -2
  74. package/react/hooks/useSubscription.js +3 -3
  75. package/react/hooks/useSuspenseQuery.js +2 -2
  76. package/react/hooks/useSyncExternalStore.js +1 -1
  77. package/react/internal/cache/QueryReference.js +2 -2
  78. package/react/internal/cache/QueryReference.js.map +1 -1
  79. package/react/internal/internal.cjs +3 -3
  80. package/react/internal/internal.cjs.map +1 -1
  81. package/react/internal/internal.cjs.native.js +3 -3
  82. package/react/parser/index.js +5 -5
  83. package/react/parser/parser.cjs +5 -5
  84. package/react/parser/parser.cjs.map +1 -1
  85. package/react/parser/parser.cjs.native.js +5 -5
  86. package/testing/core/core.cjs +2 -2
  87. package/testing/core/core.cjs.map +1 -1
  88. package/testing/core/core.cjs.native.js +2 -2
  89. package/testing/core/mocking/mockLink.js +2 -2
  90. package/testing/internal/ObservableStream.d.ts +11 -15
  91. package/testing/internal/ObservableStream.js +18 -62
  92. package/testing/internal/ObservableStream.js.map +1 -1
  93. package/testing/internal/index.d.ts +1 -2
  94. package/testing/internal/index.js +1 -2
  95. package/testing/internal/index.js.map +1 -1
  96. package/testing/internal/renderHelpers.d.ts +13 -2
  97. package/testing/internal/renderHelpers.js +20 -12
  98. package/testing/internal/renderHelpers.js.map +1 -1
  99. package/testing/matchers/index.js +0 -3
  100. package/testing/matchers/index.js.map +1 -1
  101. package/utilities/globals/globals.cjs +1 -1
  102. package/utilities/globals/globals.cjs.map +1 -1
  103. package/utilities/globals/globals.cjs.native.js +1 -1
  104. package/utilities/graphql/DocumentTransform.js +1 -1
  105. package/utilities/graphql/directives.js +7 -7
  106. package/utilities/graphql/fragments.d.ts +1 -0
  107. package/utilities/graphql/fragments.js +18 -3
  108. package/utilities/graphql/fragments.js.map +1 -1
  109. package/utilities/graphql/getFromAST.js +8 -8
  110. package/utilities/graphql/storeUtils.js +1 -1
  111. package/utilities/graphql/transform.js +8 -2
  112. package/utilities/graphql/transform.js.map +1 -1
  113. package/utilities/index.d.ts +1 -1
  114. package/utilities/index.js +1 -1
  115. package/utilities/index.js.map +1 -1
  116. package/utilities/utilities.cjs +41 -22
  117. package/utilities/utilities.cjs.map +1 -1
  118. package/utilities/utilities.cjs.native.js +41 -22
  119. package/version.js +1 -1
  120. package/testing/internal/profile/Render.d.ts +0 -69
  121. package/testing/internal/profile/Render.js +0 -144
  122. package/testing/internal/profile/Render.js.map +0 -1
  123. package/testing/internal/profile/context.d.ts +0 -10
  124. package/testing/internal/profile/context.js +0 -14
  125. package/testing/internal/profile/context.js.map +0 -1
  126. package/testing/internal/profile/index.d.ts +0 -4
  127. package/testing/internal/profile/index.js +0 -2
  128. package/testing/internal/profile/index.js.map +0 -1
  129. package/testing/internal/profile/profile.d.ts +0 -109
  130. package/testing/internal/profile/profile.js +0 -304
  131. package/testing/internal/profile/profile.js.map +0 -1
  132. package/testing/internal/profile/traces.d.ts +0 -7
  133. package/testing/internal/profile/traces.js +0 -30
  134. package/testing/internal/profile/traces.js.map +0 -1
  135. package/testing/matchers/ProfiledComponent.d.ts +0 -8
  136. package/testing/matchers/ProfiledComponent.js +0 -110
  137. package/testing/matchers/ProfiledComponent.js.map +0 -1
package/apollo-client.cjs CHANGED
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib = require('tslib');
6
6
  var tsInvariant = require('ts-invariant');
7
7
  var equal = require('@wry/equality');
8
- var caches = require('@wry/caches');
9
8
  var graphql = require('graphql');
9
+ var caches = require('@wry/caches');
10
10
  var zenObservableTs = require('zen-observable-ts');
11
11
  require('symbol-observable');
12
12
  var trie = require('@wry/trie');
@@ -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.12.0-alpha.0";
34
+ var version = "3.12.0-rc.0";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -145,7 +145,7 @@ function shouldInclude(_a, variables) {
145
145
  if (ifArgument.value.kind === "Variable") {
146
146
  evaledValue =
147
147
  variables && variables[ifArgument.value.name.value];
148
- invariant(evaledValue !== void 0, 77, directive.name.value);
148
+ invariant(evaledValue !== void 0, 78, directive.name.value);
149
149
  }
150
150
  else {
151
151
  evaledValue = ifArgument.value.value;
@@ -180,12 +180,12 @@ function getInclusionDirectives(directives) {
180
180
  return;
181
181
  var directiveArguments = directive.arguments;
182
182
  var directiveName = directive.name.value;
183
- invariant(directiveArguments && directiveArguments.length === 1, 78, directiveName);
183
+ invariant(directiveArguments && directiveArguments.length === 1, 79, directiveName);
184
184
  var ifArgument = directiveArguments[0];
185
- invariant(ifArgument.name && ifArgument.name.value === "if", 79, directiveName);
185
+ invariant(ifArgument.name && ifArgument.name.value === "if", 80, directiveName);
186
186
  var ifValue = ifArgument.value;
187
187
  invariant(ifValue &&
188
- (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 80, directiveName);
188
+ (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 81, directiveName);
189
189
  result.push({ directive: directive, ifArgument: ifArgument });
190
190
  });
191
191
  }
@@ -207,13 +207,13 @@ function getFragmentMaskMode(fragment) {
207
207
  if (globalThis.__DEV__ !== false) {
208
208
  if (modeArg) {
209
209
  if (modeArg.value.kind === graphql.Kind.VARIABLE) {
210
- globalThis.__DEV__ !== false && invariant.warn(81);
210
+ globalThis.__DEV__ !== false && invariant.warn(82);
211
211
  }
212
212
  else if (modeArg.value.kind !== graphql.Kind.STRING) {
213
- globalThis.__DEV__ !== false && invariant.warn(82);
213
+ globalThis.__DEV__ !== false && invariant.warn(83);
214
214
  }
215
215
  else if (modeArg.value.value !== "migrate") {
216
- globalThis.__DEV__ !== false && invariant.warn(83, modeArg.value.value);
216
+ globalThis.__DEV__ !== false && invariant.warn(84, modeArg.value.value);
217
217
  }
218
218
  }
219
219
  }
@@ -246,7 +246,7 @@ function getFragmentQueryDocument(document, fragmentName) {
246
246
  document.definitions.forEach(function (definition) {
247
247
  if (definition.kind === "OperationDefinition") {
248
248
  throw newInvariantError(
249
- 84,
249
+ 85,
250
250
  definition.operation,
251
251
  definition.name ? " named '".concat(definition.name.value, "'") : ""
252
252
  );
@@ -256,7 +256,7 @@ function getFragmentQueryDocument(document, fragmentName) {
256
256
  }
257
257
  });
258
258
  if (typeof actualFragmentName === "undefined") {
259
- invariant(fragments.length === 1, 85, fragments.length);
259
+ invariant(fragments.length === 1, 86, fragments.length);
260
260
  actualFragmentName = fragments[0].name.value;
261
261
  }
262
262
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -297,13 +297,27 @@ function getFragmentFromSelection(selection, fragmentMap) {
297
297
  return fragmentMap(fragmentName);
298
298
  }
299
299
  var fragment = fragmentMap && fragmentMap[fragmentName];
300
- invariant(fragment, 86, fragmentName);
300
+ invariant(fragment, 87, fragmentName);
301
301
  return fragment || null;
302
302
  }
303
303
  default:
304
304
  return null;
305
305
  }
306
306
  }
307
+ function isFullyUnmaskedOperation(document) {
308
+ var isUnmasked = true;
309
+ graphql.visit(document, {
310
+ FragmentSpread: function (node) {
311
+ isUnmasked =
312
+ !!node.directives &&
313
+ node.directives.some(function (directive) { return directive.name.value === "unmask"; });
314
+ if (!isUnmasked) {
315
+ return graphql.BREAK;
316
+ }
317
+ },
318
+ });
319
+ return isUnmasked;
320
+ }
307
321
 
308
322
  var scheduledCleanup = new WeakSet();
309
323
  function schedule(cache) {
@@ -548,7 +562,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
548
562
  argObj[name.value] = null;
549
563
  }
550
564
  else {
551
- throw newInvariantError(95, name.value, value.kind);
565
+ throw newInvariantError(96, name.value, value.kind);
552
566
  }
553
567
  }
554
568
  function storeKeyNameFromField(field, variables) {
@@ -682,16 +696,16 @@ function isInlineFragment(selection) {
682
696
  }
683
697
 
684
698
  function checkDocument(doc) {
685
- invariant(doc && doc.kind === "Document", 87);
699
+ invariant(doc && doc.kind === "Document", 88);
686
700
  var operations = doc.definitions
687
701
  .filter(function (d) { return d.kind !== "FragmentDefinition"; })
688
702
  .map(function (definition) {
689
703
  if (definition.kind !== "OperationDefinition") {
690
- throw newInvariantError(88, definition.kind);
704
+ throw newInvariantError(89, definition.kind);
691
705
  }
692
706
  return definition;
693
707
  });
694
- invariant(operations.length <= 1, 89, operations.length);
708
+ invariant(operations.length <= 1, 90, operations.length);
695
709
  return doc;
696
710
  }
697
711
  function getOperationDefinition(doc) {
@@ -714,14 +728,14 @@ function getFragmentDefinitions(doc) {
714
728
  }
715
729
  function getQueryDefinition(doc) {
716
730
  var queryDef = getOperationDefinition(doc);
717
- invariant(queryDef && queryDef.operation === "query", 90);
731
+ invariant(queryDef && queryDef.operation === "query", 91);
718
732
  return queryDef;
719
733
  }
720
734
  function getFragmentDefinition(doc) {
721
- invariant(doc.kind === "Document", 91);
722
- invariant(doc.definitions.length <= 1, 92);
735
+ invariant(doc.kind === "Document", 92);
736
+ invariant(doc.definitions.length <= 1, 93);
723
737
  var fragmentDef = doc.definitions[0];
724
- invariant(fragmentDef.kind === "FragmentDefinition", 93);
738
+ invariant(fragmentDef.kind === "FragmentDefinition", 94);
725
739
  return fragmentDef;
726
740
  }
727
741
  function getMainDefinition(queryDoc) {
@@ -744,7 +758,7 @@ function getMainDefinition(queryDoc) {
744
758
  if (fragmentDefinition) {
745
759
  return fragmentDefinition;
746
760
  }
747
- throw newInvariantError(94);
761
+ throw newInvariantError(95);
748
762
  }
749
763
  function getDefaultValues(definition) {
750
764
  var defaultValues = Object.create(null);
@@ -795,7 +809,7 @@ var DocumentTransform = (function () {
795
809
  makeCacheKey: function (document) {
796
810
  var cacheKeys = _this.getCacheKey(document);
797
811
  if (cacheKeys) {
798
- invariant(Array.isArray(cacheKeys), 76);
812
+ invariant(Array.isArray(cacheKeys), 77);
799
813
  return stableCacheKeys_1.lookupArray(cacheKeys);
800
814
  }
801
815
  },
@@ -925,7 +939,7 @@ function removeDirectivesFromDocument(directives, doc) {
925
939
  return getInUseByFragmentName(ancestor.name.value);
926
940
  }
927
941
  }
928
- globalThis.__DEV__ !== false && invariant.error(96);
942
+ globalThis.__DEV__ !== false && invariant.error(97);
929
943
  return null;
930
944
  };
931
945
  var operationCount = 0;
@@ -1138,6 +1152,10 @@ function addNonReactiveToNamedFragments(document) {
1138
1152
  checkDocument(document);
1139
1153
  return graphql.visit(document, {
1140
1154
  FragmentSpread: function (node) {
1155
+ var _a;
1156
+ if ((_a = node.directives) === null || _a === void 0 ? void 0 : _a.some(function (directive) { return directive.name.value === "unmask"; })) {
1157
+ return;
1158
+ }
1141
1159
  return tslib.__assign(tslib.__assign({}, node), { directives: tslib.__spreadArray(tslib.__spreadArray([], (node.directives || []), true), [
1142
1160
  {
1143
1161
  kind: graphql.Kind.DIRECTIVE,
@@ -1597,7 +1615,7 @@ function toPromise(observable) {
1597
1615
  observable.subscribe({
1598
1616
  next: function (data) {
1599
1617
  if (completed) {
1600
- globalThis.__DEV__ !== false && invariant.warn(50);
1618
+ globalThis.__DEV__ !== false && invariant.warn(51);
1601
1619
  }
1602
1620
  else {
1603
1621
  completed = true;
@@ -1640,7 +1658,7 @@ function validateOperation(operation) {
1640
1658
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
1641
1659
  var key = _a[_i];
1642
1660
  if (OPERATION_FIELDS.indexOf(key) < 0) {
1643
- throw newInvariantError(51, key);
1661
+ throw newInvariantError(52, key);
1644
1662
  }
1645
1663
  }
1646
1664
  return operation;
@@ -1749,7 +1767,7 @@ var ApolloLink = (function () {
1749
1767
  ApolloLink.concat = function (first, second) {
1750
1768
  var firstLink = toLink(first);
1751
1769
  if (isTerminating(firstLink)) {
1752
- globalThis.__DEV__ !== false && invariant.warn(43, firstLink);
1770
+ globalThis.__DEV__ !== false && invariant.warn(44, firstLink);
1753
1771
  return firstLink;
1754
1772
  }
1755
1773
  var nextLink = toLink(second);
@@ -1775,7 +1793,7 @@ var ApolloLink = (function () {
1775
1793
  return ApolloLink.concat(this, next);
1776
1794
  };
1777
1795
  ApolloLink.prototype.request = function (operation, forward) {
1778
- throw newInvariantError(44);
1796
+ throw newInvariantError(45);
1779
1797
  };
1780
1798
  ApolloLink.prototype.onError = function (error, observer) {
1781
1799
  if (observer && observer.error) {
@@ -2157,7 +2175,7 @@ var serializeFetchParameter = function (p, label) {
2157
2175
  serialized = JSON.stringify(p);
2158
2176
  }
2159
2177
  catch (e) {
2160
- var parseError = newInvariantError(47, label, e.message);
2178
+ var parseError = newInvariantError(48, label, e.message);
2161
2179
  parseError.parseError = e;
2162
2180
  throw parseError;
2163
2181
  }
@@ -2243,7 +2261,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
2243
2261
 
2244
2262
  var checkFetcher = function (fetcher) {
2245
2263
  if (!fetcher && typeof fetch === "undefined") {
2246
- throw newInvariantError(45);
2264
+ throw newInvariantError(46);
2247
2265
  }
2248
2266
  };
2249
2267
 
@@ -2377,7 +2395,7 @@ var createHttpLink = function (linkOptions) {
2377
2395
  options.headers = options.headers || {};
2378
2396
  var acceptHeader = "multipart/mixed;";
2379
2397
  if (isSubscription && hasDefer) {
2380
- globalThis.__DEV__ !== false && invariant.warn(46);
2398
+ globalThis.__DEV__ !== false && invariant.warn(47);
2381
2399
  }
2382
2400
  if (isSubscription) {
2383
2401
  acceptHeader +=
@@ -2511,6 +2529,7 @@ function directiveIsNonreactive(dir) {
2511
2529
  return dir.name.value === "nonreactive";
2512
2530
  }
2513
2531
 
2532
+ var disableWarningsSlot = new optimism.Slot();
2514
2533
  function maskOperation(data, document, cache) {
2515
2534
  var _a;
2516
2535
  if (!cache.fragmentMatches) {
@@ -2520,7 +2539,7 @@ function maskOperation(data, document, cache) {
2520
2539
  return data;
2521
2540
  }
2522
2541
  var definition = getOperationDefinition(document);
2523
- invariant(definition, 37);
2542
+ invariant(definition, 38);
2524
2543
  if (data == null) {
2525
2544
  return data;
2526
2545
  }
@@ -2532,9 +2551,7 @@ function maskOperation(data, document, cache) {
2532
2551
  };
2533
2552
  var _b = maskSelectionSet(data, definition.selectionSet, context), masked = _b[0], changed = _b[1];
2534
2553
  if (Object.isFrozen(data)) {
2535
- context.disableWarnings = true;
2536
- maybeDeepFreeze(masked);
2537
- context.disableWarnings = false;
2554
+ disableWarningsSlot.withValue(true, maybeDeepFreeze, [masked]);
2538
2555
  }
2539
2556
  return changed ? masked : data;
2540
2557
  }
@@ -2549,14 +2566,17 @@ function maskFragment(data, document, cache, fragmentName) {
2549
2566
  return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
2550
2567
  });
2551
2568
  if (typeof fragmentName === "undefined") {
2552
- invariant(fragments.length === 1, 38, fragments.length);
2569
+ invariant(fragments.length === 1, 39, fragments.length);
2553
2570
  fragmentName = fragments[0].name.value;
2554
2571
  }
2555
2572
  var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
2556
- invariant(!!fragment, 39, fragmentName);
2573
+ invariant(!!fragment, 40, fragmentName);
2557
2574
  if (data == null) {
2558
2575
  return data;
2559
2576
  }
2577
+ if (equal.equal(data, {})) {
2578
+ return data;
2579
+ }
2560
2580
  var context = {
2561
2581
  operationType: "fragment",
2562
2582
  operationName: fragment.name.value,
@@ -2565,9 +2585,7 @@ function maskFragment(data, document, cache, fragmentName) {
2565
2585
  };
2566
2586
  var _a = maskSelectionSet(data, fragment.selectionSet, context), masked = _a[0], changed = _a[1];
2567
2587
  if (Object.isFrozen(data)) {
2568
- context.disableWarnings = true;
2569
- maybeDeepFreeze(masked);
2570
- context.disableWarnings = false;
2588
+ disableWarningsSlot.withValue(true, maybeDeepFreeze, [masked]);
2571
2589
  }
2572
2590
  return changed ? masked : data;
2573
2591
  }
@@ -2591,7 +2609,10 @@ function maskSelectionSet(data, selectionSet, context, path) {
2591
2609
  var keyName = resultKeyNameFromField(selection);
2592
2610
  var childSelectionSet = selection.selectionSet;
2593
2611
  memo[keyName] = data[keyName];
2594
- if (childSelectionSet && data[keyName] !== null) {
2612
+ if (memo[keyName] === void 0) {
2613
+ delete memo[keyName];
2614
+ }
2615
+ if (keyName in memo && childSelectionSet && data[keyName] !== null) {
2595
2616
  var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
2596
2617
  if (childChanged ||
2597
2618
  Object.keys(masked).length !== Object.keys(data[keyName]).length) {
@@ -2617,7 +2638,7 @@ function maskSelectionSet(data, selectionSet, context, path) {
2617
2638
  var fragment = context.fragmentMap[fragmentName] ||
2618
2639
  (context.fragmentMap[fragmentName] =
2619
2640
  context.cache.lookupFragment(fragmentName));
2620
- invariant(fragment, 40, fragmentName);
2641
+ invariant(fragment, 41, fragmentName);
2621
2642
  var mode = getFragmentMaskMode(selection);
2622
2643
  if (mode === "mask") {
2623
2644
  return [memo, true];
@@ -2635,7 +2656,7 @@ function maskSelectionSet(data, selectionSet, context, path) {
2635
2656
  }
2636
2657
  }
2637
2658
  }, [Object.create(null), false]);
2638
- if ("__typename" in data && !("__typename" in result[0])) {
2659
+ if (data && "__typename" in data && !("__typename" in result[0])) {
2639
2660
  result[0].__typename = data.__typename;
2640
2661
  }
2641
2662
  return result;
@@ -2685,11 +2706,14 @@ function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
2685
2706
  }, memo);
2686
2707
  }
2687
2708
  function addAccessorWarning(data, value, fieldName, path, context) {
2709
+ if (value === void 0) {
2710
+ return;
2711
+ }
2688
2712
  var getValue = function () {
2689
- if (context.disableWarnings) {
2713
+ if (disableWarningsSlot.getValue()) {
2690
2714
  return value;
2691
2715
  }
2692
- globalThis.__DEV__ !== false && invariant.warn(41, context.operationName ?
2716
+ globalThis.__DEV__ !== false && invariant.warn(42, context.operationName ?
2693
2717
  "".concat(context.operationType, " '").concat(context.operationName, "'")
2694
2718
  : "anonymous ".concat(context.operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
2695
2719
  getValue = function () { return value; };
@@ -2710,7 +2734,7 @@ var issuedWarning = false;
2710
2734
  function warnOnImproperCacheImplementation() {
2711
2735
  if (!issuedWarning) {
2712
2736
  issuedWarning = true;
2713
- globalThis.__DEV__ !== false && invariant.warn(42);
2737
+ globalThis.__DEV__ !== false && invariant.warn(43);
2714
2738
  }
2715
2739
  }
2716
2740
 
@@ -4060,16 +4084,18 @@ var Policies = (function () {
4060
4084
  var id;
4061
4085
  var policy = typename && this.getTypePolicy(typename);
4062
4086
  var keyFn = (policy && policy.keyFn) || this.config.dataIdFromObject;
4063
- while (keyFn) {
4064
- var specifierOrId = keyFn(tslib.__assign(tslib.__assign({}, object), storeObject), context);
4065
- if (isArray(specifierOrId)) {
4066
- keyFn = keyFieldsFnFromSpecifier(specifierOrId);
4067
- }
4068
- else {
4069
- id = specifierOrId;
4070
- break;
4087
+ disableWarningsSlot.withValue(true, function () {
4088
+ while (keyFn) {
4089
+ var specifierOrId = keyFn(tslib.__assign(tslib.__assign({}, object), storeObject), context);
4090
+ if (isArray(specifierOrId)) {
4091
+ keyFn = keyFieldsFnFromSpecifier(specifierOrId);
4092
+ }
4093
+ else {
4094
+ id = specifierOrId;
4095
+ break;
4096
+ }
4071
4097
  }
4072
- }
4098
+ });
4073
4099
  id = id ? String(id) : void 0;
4074
4100
  return context.keyObject ? [id, context.keyObject] : [id];
4075
4101
  };
@@ -5724,6 +5750,8 @@ var ObservableQuery = (function (_super) {
5724
5750
  return result && "data" in result ? tslib.__assign(tslib.__assign({}, result), { data: this.queryManager.maskOperation({
5725
5751
  document: this.query,
5726
5752
  data: result.data,
5753
+ fetchPolicy: this.options.fetchPolicy,
5754
+ id: this.queryId,
5727
5755
  }) }) : result;
5728
5756
  };
5729
5757
  return ObservableQuery;
@@ -6051,6 +6079,7 @@ var QueryManager = (function () {
6051
6079
  this.requestIdCounter = 1;
6052
6080
  this.mutationIdCounter = 1;
6053
6081
  this.inFlightLinkObservables = new trie.Trie(false);
6082
+ this.noCacheWarningsByQueryId = new Set();
6054
6083
  var defaultDocumentTransform = new DocumentTransform(function (document) { return _this.cache.transformDocument(document); },
6055
6084
  { cache: false });
6056
6085
  this.cache = options.cache;
@@ -6167,6 +6196,8 @@ var QueryManager = (function () {
6167
6196
  resolve(tslib.__assign(tslib.__assign({}, storeResult), { data: self.maskOperation({
6168
6197
  document: mutation,
6169
6198
  data: storeResult.data,
6199
+ fetchPolicy: fetchPolicy,
6200
+ id: mutationId,
6170
6201
  }) }));
6171
6202
  }
6172
6203
  },
@@ -6428,7 +6459,12 @@ var QueryManager = (function () {
6428
6459
  var query = this.transform(options.query);
6429
6460
  return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: query }))
6430
6461
  .then(function (result) {
6431
- return result && tslib.__assign(tslib.__assign({}, result), { data: _this.maskOperation({ document: query, data: result.data }) });
6462
+ return result && tslib.__assign(tslib.__assign({}, result), { data: _this.maskOperation({
6463
+ document: query,
6464
+ data: result.data,
6465
+ fetchPolicy: options.fetchPolicy,
6466
+ id: queryId,
6467
+ }) });
6432
6468
  })
6433
6469
  .finally(function () { return _this.stopQuery(queryId); });
6434
6470
  };
@@ -6841,7 +6877,23 @@ var QueryManager = (function () {
6841
6877
  return results;
6842
6878
  };
6843
6879
  QueryManager.prototype.maskOperation = function (options) {
6880
+ var _a, _b, _c;
6844
6881
  var document = options.document, data = options.data;
6882
+ if (globalThis.__DEV__ !== false) {
6883
+ var fetchPolicy = options.fetchPolicy, id = options.id;
6884
+ var operationType = (_a = getOperationDefinition(document)) === null || _a === void 0 ? void 0 : _a.operation;
6885
+ var operationId = ((_b = operationType === null || operationType === void 0 ? void 0 : operationType[0]) !== null && _b !== void 0 ? _b : "o") + id;
6886
+ if (this.dataMasking &&
6887
+ fetchPolicy === "no-cache" &&
6888
+ !isFullyUnmaskedOperation(document) &&
6889
+ !this.noCacheWarningsByQueryId.has(operationId)) {
6890
+ this.noCacheWarningsByQueryId.add(operationId);
6891
+ globalThis.__DEV__ !== false && invariant.warn(
6892
+ 37,
6893
+ (_c = getOperationName(document)) !== null && _c !== void 0 ? _c : "Unnamed ".concat(operationType !== null && operationType !== void 0 ? operationType : "operation")
6894
+ );
6895
+ }
6896
+ }
6845
6897
  return (this.dataMasking ?
6846
6898
  maskOperation(data, document, this.cache)
6847
6899
  : data);
@@ -7293,13 +7345,14 @@ var hasSuggestedDevtools = false;
7293
7345
  var ApolloClient = (function () {
7294
7346
  function ApolloClient(options) {
7295
7347
  var _this = this;
7348
+ var _a;
7296
7349
  this.resetStoreCallbacks = [];
7297
7350
  this.clearStoreCallbacks = [];
7298
7351
  if (!options.cache) {
7299
7352
  throw newInvariantError(16);
7300
7353
  }
7301
- var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b,
7302
- connectToDevTools = options.connectToDevTools, _c = options.queryDeduplication, queryDeduplication = _c === void 0 ? true : _c, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _d = options.assumeImmutableResults, assumeImmutableResults = _d === void 0 ? cache.assumeImmutableResults : _d, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version, devtools = options.devtools, dataMasking = options.dataMasking;
7354
+ var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _b = options.ssrMode, ssrMode = _b === void 0 ? false : _b, _c = options.ssrForceFetchDelay, ssrForceFetchDelay = _c === void 0 ? 0 : _c,
7355
+ connectToDevTools = options.connectToDevTools, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, defaultContext = options.defaultContext, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? cache.assumeImmutableResults : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version, devtools = options.devtools, dataMasking = options.dataMasking;
7303
7356
  var link = options.link;
7304
7357
  if (!link) {
7305
7358
  link =
@@ -7311,7 +7364,7 @@ var ApolloClient = (function () {
7311
7364
  this.queryDeduplication = queryDeduplication;
7312
7365
  this.defaultOptions = defaultOptions || Object.create(null);
7313
7366
  this.typeDefs = typeDefs;
7314
- this.devtoolsConfig = tslib.__assign(tslib.__assign({}, devtools), { enabled: (devtools === null || devtools === void 0 ? void 0 : devtools.enabled) || connectToDevTools });
7367
+ this.devtoolsConfig = tslib.__assign(tslib.__assign({}, devtools), { enabled: (_a = devtools === null || devtools === void 0 ? void 0 : devtools.enabled) !== null && _a !== void 0 ? _a : connectToDevTools });
7315
7368
  if (this.devtoolsConfig.enabled === undefined) {
7316
7369
  this.devtoolsConfig.enabled = globalThis.__DEV__ !== false;
7317
7370
  }
@@ -7442,11 +7495,14 @@ var ApolloClient = (function () {
7442
7495
  };
7443
7496
  ApolloClient.prototype.subscribe = function (options) {
7444
7497
  var _this = this;
7498
+ var id = this.queryManager.generateQueryId();
7445
7499
  return this.queryManager
7446
7500
  .startGraphQLSubscription(options)
7447
7501
  .map(function (result) { return (tslib.__assign(tslib.__assign({}, result), { data: _this.queryManager.maskOperation({
7448
7502
  document: options.query,
7449
7503
  data: result.data,
7504
+ fetchPolicy: options.fetchPolicy,
7505
+ id: id,
7450
7506
  }) })); });
7451
7507
  };
7452
7508
  ApolloClient.prototype.readQuery = function (options, optimistic) {
@@ -7575,7 +7631,7 @@ if (globalThis.__DEV__ !== false) {
7575
7631
 
7576
7632
  var contextKey = canUseSymbol ? Symbol.for("__APOLLO_CONTEXT__") : "__APOLLO_CONTEXT__";
7577
7633
  function getApolloContext() {
7578
- invariant("createContext" in React__namespace, 53);
7634
+ invariant("createContext" in React__namespace, 54);
7579
7635
  var context = React__namespace.createContext[contextKey];
7580
7636
  if (!context) {
7581
7637
  Object.defineProperty(React__namespace.createContext, contextKey, {
@@ -7593,7 +7649,7 @@ var resetApolloContext = getApolloContext;
7593
7649
  var ApolloConsumer = function (props) {
7594
7650
  var ApolloContext = getApolloContext();
7595
7651
  return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
7596
- invariant(context && context.client, 52);
7652
+ invariant(context && context.client, 53);
7597
7653
  return props.children(context.client);
7598
7654
  }));
7599
7655
  };
@@ -7605,14 +7661,14 @@ var ApolloProvider = function (_a) {
7605
7661
  var context = React__namespace.useMemo(function () {
7606
7662
  return tslib.__assign(tslib.__assign({}, parentContext), { client: client || parentContext.client });
7607
7663
  }, [parentContext, client]);
7608
- invariant(context.client, 54);
7664
+ invariant(context.client, 55);
7609
7665
  return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
7610
7666
  };
7611
7667
 
7612
7668
  function useApolloClient(override) {
7613
7669
  var context = React__namespace.useContext(getApolloContext());
7614
7670
  var client = override || context.client;
7615
- invariant(!!client, 57);
7671
+ invariant(!!client, 58);
7616
7672
  return client;
7617
7673
  }
7618
7674
 
@@ -7627,7 +7683,7 @@ var useSyncExternalStore = realHook$1 ||
7627
7683
  !didWarnUncachedGetSnapshot &&
7628
7684
  value !== getSnapshot()) {
7629
7685
  didWarnUncachedGetSnapshot = true;
7630
- globalThis.__DEV__ !== false && invariant.error(67);
7686
+ globalThis.__DEV__ !== false && invariant.error(68);
7631
7687
  }
7632
7688
  var _a = React__namespace.useState({
7633
7689
  inst: { value: value, getSnapshot: getSnapshot },
@@ -7695,7 +7751,7 @@ function parser(document) {
7695
7751
  if (cached)
7696
7752
  return cached;
7697
7753
  var variables, type, name;
7698
- invariant(!!document && !!document.kind, 69, document);
7754
+ invariant(!!document && !!document.kind, 70, document);
7699
7755
  var fragments = [];
7700
7756
  var queries = [];
7701
7757
  var mutations = [];
@@ -7723,10 +7779,10 @@ function parser(document) {
7723
7779
  invariant(!fragments.length ||
7724
7780
  queries.length ||
7725
7781
  mutations.length ||
7726
- subscriptions.length, 70);
7782
+ subscriptions.length, 71);
7727
7783
  invariant(
7728
7784
  queries.length + mutations.length + subscriptions.length <= 1,
7729
- 71,
7785
+ 72,
7730
7786
  document,
7731
7787
  queries.length,
7732
7788
  subscriptions.length,
@@ -7738,7 +7794,7 @@ function parser(document) {
7738
7794
  var definitions = queries.length ? queries
7739
7795
  : mutations.length ? mutations
7740
7796
  : subscriptions;
7741
- invariant(definitions.length === 1, 72, document, definitions.length);
7797
+ invariant(definitions.length === 1, 73, document, definitions.length);
7742
7798
  var definition = definitions[0];
7743
7799
  variables = definition.variableDefinitions || [];
7744
7800
  if (definition.name && definition.name.kind === "Name") {
@@ -7763,7 +7819,7 @@ function verifyDocumentType(document, type) {
7763
7819
  var usedOperationName = operationName(operation.type);
7764
7820
  invariant(
7765
7821
  operation.type === type,
7766
- 73,
7822
+ 74,
7767
7823
  requiredOperationName,
7768
7824
  requiredOperationName,
7769
7825
  usedOperationName
@@ -8336,10 +8392,10 @@ function useSubscription(subscription, options) {
8336
8392
  if (!hasIssuedDeprecationWarningRef.current) {
8337
8393
  hasIssuedDeprecationWarningRef.current = true;
8338
8394
  if (options.onSubscriptionData) {
8339
- globalThis.__DEV__ !== false && invariant.warn(options.onData ? 60 : 61);
8395
+ globalThis.__DEV__ !== false && invariant.warn(options.onData ? 61 : 62);
8340
8396
  }
8341
8397
  if (options.onSubscriptionComplete) {
8342
- globalThis.__DEV__ !== false && invariant.warn(options.onComplete ? 62 : 63);
8398
+ globalThis.__DEV__ !== false && invariant.warn(options.onComplete ? 63 : 64);
8343
8399
  }
8344
8400
  }
8345
8401
  var skip = options.skip, fetchPolicy = options.fetchPolicy, errorPolicy = options.errorPolicy, shouldResubscribe = options.shouldResubscribe, context = options.context, extensions = options.extensions, ignoreResults = options.ignoreResults;
@@ -8460,7 +8516,7 @@ function useSubscription(subscription, options) {
8460
8516
  : fallbackResult;
8461
8517
  }, function () { return fallbackResult; });
8462
8518
  var restart = React__namespace.useCallback(function () {
8463
- invariant(!optionsRef.current.skip, 64);
8519
+ invariant(!optionsRef.current.skip, 65);
8464
8520
  setObservable(recreateRef.current());
8465
8521
  }, [optionsRef, recreateRef]);
8466
8522
  return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: restart })); }, [ret, restart]);
@@ -8568,7 +8624,7 @@ function wrapQueryRef(internalQueryRef) {
8568
8624
  return ref;
8569
8625
  }
8570
8626
  function assertWrappedQueryRef(queryRef) {
8571
- invariant(!queryRef || QUERY_REFERENCE_SYMBOL in queryRef, 68);
8627
+ invariant(!queryRef || QUERY_REFERENCE_SYMBOL in queryRef, 69);
8572
8628
  }
8573
8629
  function getWrappedPromise(queryRef) {
8574
8630
  var internalQueryRef = unwrapQueryRef(queryRef);
@@ -8785,7 +8841,7 @@ var InternalQueryReference = (function () {
8785
8841
  }
8786
8842
  });
8787
8843
  })
8788
- .catch(function () { });
8844
+ .catch(function (error) { var _a; return (_a = _this.reject) === null || _a === void 0 ? void 0 : _a.call(_this, error); });
8789
8845
  return returnedPromise;
8790
8846
  };
8791
8847
  InternalQueryReference.prototype.subscribeToQuery = function () {
@@ -8939,11 +8995,11 @@ function validateFetchPolicy(fetchPolicy) {
8939
8995
  "no-cache",
8940
8996
  "cache-and-network",
8941
8997
  ];
8942
- invariant(supportedFetchPolicies.includes(fetchPolicy), 65, fetchPolicy);
8998
+ invariant(supportedFetchPolicies.includes(fetchPolicy), 66, fetchPolicy);
8943
8999
  }
8944
9000
  function validatePartialDataReturn(fetchPolicy, returnPartialData) {
8945
9001
  if (fetchPolicy === "no-cache" && returnPartialData) {
8946
- globalThis.__DEV__ !== false && invariant.warn(66);
9002
+ globalThis.__DEV__ !== false && invariant.warn(67);
8947
9003
  }
8948
9004
  }
8949
9005
  function toApolloError(result) {
@@ -9063,7 +9119,7 @@ function useLoadableQuery(query, options) {
9063
9119
  for (var _i = 0; _i < arguments.length; _i++) {
9064
9120
  args[_i] = arguments[_i];
9065
9121
  }
9066
- invariant(!calledDuringRender(), 58);
9122
+ invariant(!calledDuringRender(), 59);
9067
9123
  var variables = args[0];
9068
9124
  var cacheKey = tslib.__spreadArray([
9069
9125
  query,
@@ -9082,7 +9138,7 @@ function useLoadableQuery(query, options) {
9082
9138
  client,
9083
9139
  ]);
9084
9140
  var subscribeToMore = React__namespace.useCallback(function (options) {
9085
- invariant(internalQueryRef, 59);
9141
+ invariant(internalQueryRef, 60);
9086
9142
  return internalQueryRef.observable.subscribeToMore(options);
9087
9143
  }, [internalQueryRef]);
9088
9144
  var reset = React__namespace.useCallback(function () {