@apollo/client 3.11.7 → 3.12.0-alpha.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 (187) hide show
  1. package/.changeset/nasty-camels-pay.md +36 -0
  2. package/.changeset/pre.json +10 -0
  3. package/CHANGELOG.md +43 -0
  4. package/apollo-client.cjs +438 -111
  5. package/apollo-client.cjs.map +1 -1
  6. package/apollo-client.min.cjs +1 -1
  7. package/cache/cache.cjs +218 -22
  8. package/cache/cache.cjs.map +1 -1
  9. package/cache/cache.cjs.native.js +218 -22
  10. package/cache/core/cache.d.ts +13 -10
  11. package/cache/core/cache.js +32 -14
  12. package/cache/core/cache.js.map +1 -1
  13. package/cache/core/types/Cache.d.ts +2 -1
  14. package/cache/core/types/Cache.js.map +1 -1
  15. package/cache/core/types/DataProxy.d.ts +4 -3
  16. package/cache/core/types/DataProxy.js.map +1 -1
  17. package/cache/inmemory/entityStore.js +3 -3
  18. package/cache/inmemory/inMemoryCache.d.ts +3 -1
  19. package/cache/inmemory/inMemoryCache.js +7 -0
  20. package/cache/inmemory/inMemoryCache.js.map +1 -1
  21. package/cache/inmemory/key-extractor.js +1 -1
  22. package/cache/inmemory/policies.js +4 -4
  23. package/cache/inmemory/readFromStore.js +2 -2
  24. package/cache/inmemory/writeToStore.js +4 -4
  25. package/core/ApolloClient.d.ts +14 -6
  26. package/core/ApolloClient.js +14 -6
  27. package/core/ApolloClient.js.map +1 -1
  28. package/core/LocalState.js +2 -2
  29. package/core/ObservableQuery.d.ts +17 -14
  30. package/core/ObservableQuery.js +29 -16
  31. package/core/ObservableQuery.js.map +1 -1
  32. package/core/QueryInfo.js.map +1 -1
  33. package/core/QueryManager.d.ts +18 -3
  34. package/core/QueryManager.js +39 -14
  35. package/core/QueryManager.js.map +1 -1
  36. package/core/core.cjs +285 -37
  37. package/core/core.cjs.map +1 -1
  38. package/core/core.cjs.native.js +285 -37
  39. package/core/index.d.ts +1 -0
  40. package/core/index.js.map +1 -1
  41. package/core/masking.d.ts +4 -0
  42. package/core/masking.js +212 -0
  43. package/core/masking.js.map +1 -0
  44. package/core/types.d.ts +3 -2
  45. package/core/types.js.map +1 -1
  46. package/core/watchQueryOptions.d.ts +8 -6
  47. package/core/watchQueryOptions.js.map +1 -1
  48. package/dev/dev.cjs +131 -87
  49. package/dev/dev.cjs.map +1 -1
  50. package/dev/dev.cjs.native.js +131 -87
  51. package/invariantErrorCodes.js +140 -86
  52. package/link/core/ApolloLink.js +2 -2
  53. package/link/core/core.cjs +2 -2
  54. package/link/core/core.cjs.map +1 -1
  55. package/link/core/core.cjs.native.js +2 -2
  56. package/link/http/checkFetcher.js +1 -1
  57. package/link/http/createHttpLink.js +1 -1
  58. package/link/http/http.cjs +6 -6
  59. package/link/http/http.cjs.map +1 -1
  60. package/link/http/http.cjs.native.js +6 -6
  61. package/link/http/selectHttpOptionsAndBody.js +3 -3
  62. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  63. package/link/http/serializeFetchParameter.js +1 -1
  64. package/link/persisted-queries/index.js +2 -2
  65. package/link/persisted-queries/persisted-queries.cjs +2 -2
  66. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  67. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  68. package/link/utils/toPromise.js +1 -1
  69. package/link/utils/utils.cjs +2 -2
  70. package/link/utils/utils.cjs.map +1 -1
  71. package/link/utils/utils.cjs.native.js +2 -2
  72. package/link/utils/validateOperation.js +1 -1
  73. package/masking/index.d.ts +2 -0
  74. package/masking/index.js +2 -0
  75. package/masking/index.js.map +1 -0
  76. package/masking/internal/types.d.ts +15 -0
  77. package/masking/internal/types.js +2 -0
  78. package/masking/internal/types.js.map +1 -0
  79. package/masking/masking.cjs +3 -0
  80. package/masking/masking.cjs.map +1 -0
  81. package/masking/masking.cjs.native.js +3 -0
  82. package/masking/masking.d.cts +1 -0
  83. package/masking/package.json +8 -0
  84. package/masking/types.d.ts +44 -0
  85. package/masking/types.js +2 -0
  86. package/masking/types.js.map +1 -0
  87. package/package.json +2 -1
  88. package/react/context/ApolloConsumer.js +1 -1
  89. package/react/context/ApolloContext.js +1 -1
  90. package/react/context/ApolloProvider.js +1 -1
  91. package/react/context/context.cjs +3 -3
  92. package/react/context/context.cjs.map +1 -1
  93. package/react/context/context.cjs.native.js +3 -3
  94. package/react/hoc/hoc-utils.js +1 -1
  95. package/react/hoc/hoc.cjs +2 -2
  96. package/react/hoc/hoc.cjs.map +1 -1
  97. package/react/hoc/hoc.cjs.native.js +2 -2
  98. package/react/hoc/withApollo.js +1 -1
  99. package/react/hooks/hooks.cjs +24 -16
  100. package/react/hooks/hooks.cjs.map +1 -1
  101. package/react/hooks/hooks.cjs.native.js +24 -16
  102. package/react/hooks/useApolloClient.js +1 -1
  103. package/react/hooks/useFragment.d.ts +4 -3
  104. package/react/hooks/useFragment.js +12 -5
  105. package/react/hooks/useFragment.js.map +1 -1
  106. package/react/hooks/useLazyQuery.js +1 -1
  107. package/react/hooks/useLazyQuery.js.map +1 -1
  108. package/react/hooks/useLoadableQuery.js +2 -2
  109. package/react/hooks/useQuery.d.ts +4 -3
  110. package/react/hooks/useQuery.js +2 -1
  111. package/react/hooks/useQuery.js.map +1 -1
  112. package/react/hooks/useReadQuery.d.ts +2 -1
  113. package/react/hooks/useReadQuery.js.map +1 -1
  114. package/react/hooks/useSubscription.d.ts +2 -1
  115. package/react/hooks/useSubscription.js +3 -3
  116. package/react/hooks/useSubscription.js.map +1 -1
  117. package/react/hooks/useSuspenseQuery.d.ts +6 -5
  118. package/react/hooks/useSuspenseQuery.js +2 -2
  119. package/react/hooks/useSuspenseQuery.js.map +1 -1
  120. package/react/hooks/useSyncExternalStore.js +1 -1
  121. package/react/internal/cache/QueryReference.d.ts +5 -4
  122. package/react/internal/cache/QueryReference.js +1 -1
  123. package/react/internal/cache/QueryReference.js.map +1 -1
  124. package/react/internal/internal.cjs +2 -2
  125. package/react/internal/internal.cjs.map +1 -1
  126. package/react/internal/internal.cjs.native.js +2 -2
  127. package/react/parser/index.js +5 -5
  128. package/react/parser/parser.cjs +5 -5
  129. package/react/parser/parser.cjs.map +1 -1
  130. package/react/parser/parser.cjs.native.js +5 -5
  131. package/react/types/types.d.ts +18 -42
  132. package/react/types/types.js.map +1 -1
  133. package/testing/core/core.cjs +3 -3
  134. package/testing/core/core.cjs.map +1 -1
  135. package/testing/core/core.cjs.native.js +3 -3
  136. package/testing/core/mocking/mockLink.d.ts +3 -2
  137. package/testing/core/mocking/mockLink.js +3 -3
  138. package/testing/core/mocking/mockLink.js.map +1 -1
  139. package/testing/core/mocking/mockQueryManager.d.ts +1 -0
  140. package/testing/core/mocking/mockQueryManager.js +1 -1
  141. package/testing/core/mocking/mockQueryManager.js.map +1 -1
  142. package/testing/internal/disposables/index.d.ts +1 -0
  143. package/testing/internal/disposables/index.js +1 -0
  144. package/testing/internal/disposables/index.js.map +1 -1
  145. package/testing/internal/disposables/withProdMode.d.ts +4 -0
  146. package/testing/internal/disposables/withProdMode.js +10 -0
  147. package/testing/internal/disposables/withProdMode.js.map +1 -0
  148. package/testing/internal/scenarios/index.d.ts +28 -0
  149. package/testing/internal/scenarios/index.js +18 -2
  150. package/testing/internal/scenarios/index.js.map +1 -1
  151. package/utilities/common/maybeDeepFreeze.d.ts +1 -0
  152. package/utilities/common/maybeDeepFreeze.js +1 -1
  153. package/utilities/common/maybeDeepFreeze.js.map +1 -1
  154. package/utilities/globals/globals.cjs +1 -1
  155. package/utilities/globals/globals.cjs.map +1 -1
  156. package/utilities/globals/globals.cjs.native.js +1 -1
  157. package/utilities/graphql/DocumentTransform.js +1 -1
  158. package/utilities/graphql/directives.d.ts +3 -1
  159. package/utilities/graphql/directives.js +39 -5
  160. package/utilities/graphql/directives.js.map +1 -1
  161. package/utilities/graphql/fragments.js +3 -3
  162. package/utilities/graphql/getFromAST.js +8 -8
  163. package/utilities/graphql/storeUtils.js +1 -1
  164. package/utilities/graphql/transform.d.ts +1 -0
  165. package/utilities/graphql/transform.js +15 -2
  166. package/utilities/graphql/transform.js.map +1 -1
  167. package/utilities/index.d.ts +7 -3
  168. package/utilities/index.js +4 -3
  169. package/utilities/index.js.map +1 -1
  170. package/utilities/promises/preventUnhandledRejection.d.ts +2 -0
  171. package/utilities/promises/preventUnhandledRejection.js +5 -0
  172. package/utilities/promises/preventUnhandledRejection.js.map +1 -0
  173. package/utilities/subscriptions/relay/relay.cjs.map +1 -1
  174. package/utilities/subscriptions/urql/urql.cjs.map +1 -1
  175. package/utilities/types/NoInfer.d.ts +27 -0
  176. package/utilities/types/NoInfer.js +2 -0
  177. package/utilities/types/NoInfer.js.map +1 -0
  178. package/utilities/types/Prettify.d.ts +4 -0
  179. package/utilities/types/Prettify.js +2 -0
  180. package/utilities/types/Prettify.js.map +1 -0
  181. package/utilities/types/UnionToIntersection.d.ts +2 -0
  182. package/utilities/types/UnionToIntersection.js +2 -0
  183. package/utilities/types/UnionToIntersection.js.map +1 -0
  184. package/utilities/utilities.cjs +73 -19
  185. package/utilities/utilities.cjs.map +1 -1
  186. package/utilities/utilities.cjs.native.js +73 -19
  187. package/version.js +1 -1
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.11.7";
34
+ var version = "3.12.0-alpha.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, 70, directive.name.value);
148
+ invariant(evaledValue !== void 0, 77, directive.name.value);
149
149
  }
150
150
  else {
151
151
  evaledValue = ifArgument.value.value;
@@ -180,17 +180,50 @@ 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, 71, directiveName);
183
+ invariant(directiveArguments && directiveArguments.length === 1, 78, directiveName);
184
184
  var ifArgument = directiveArguments[0];
185
- invariant(ifArgument.name && ifArgument.name.value === "if", 72, directiveName);
185
+ invariant(ifArgument.name && ifArgument.name.value === "if", 79, directiveName);
186
186
  var ifValue = ifArgument.value;
187
187
  invariant(ifValue &&
188
- (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 73, directiveName);
188
+ (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 80, directiveName);
189
189
  result.push({ directive: directive, ifArgument: ifArgument });
190
190
  });
191
191
  }
192
192
  return result;
193
193
  }
194
+ function getFragmentMaskMode(fragment) {
195
+ var _a, _b;
196
+ var directive = (_a = fragment.directives) === null || _a === void 0 ? void 0 : _a.find(function (_a) {
197
+ var name = _a.name;
198
+ return name.value === "unmask";
199
+ });
200
+ if (!directive) {
201
+ return "mask";
202
+ }
203
+ var modeArg = (_b = directive.arguments) === null || _b === void 0 ? void 0 : _b.find(function (_a) {
204
+ var name = _a.name;
205
+ return name.value === "mode";
206
+ });
207
+ if (globalThis.__DEV__ !== false) {
208
+ if (modeArg) {
209
+ if (modeArg.value.kind === graphql.Kind.VARIABLE) {
210
+ globalThis.__DEV__ !== false && invariant.warn(81);
211
+ }
212
+ else if (modeArg.value.kind !== graphql.Kind.STRING) {
213
+ globalThis.__DEV__ !== false && invariant.warn(82);
214
+ }
215
+ else if (modeArg.value.value !== "migrate") {
216
+ globalThis.__DEV__ !== false && invariant.warn(83, modeArg.value.value);
217
+ }
218
+ }
219
+ }
220
+ if (modeArg &&
221
+ "value" in modeArg.value &&
222
+ modeArg.value.value === "migrate") {
223
+ return "migrate";
224
+ }
225
+ return "unmask";
226
+ }
194
227
 
195
228
  var isReactNative = maybe(function () { return navigator.product; }) == "ReactNative";
196
229
  var canUseWeakMap = typeof WeakMap === "function" &&
@@ -213,7 +246,7 @@ function getFragmentQueryDocument(document, fragmentName) {
213
246
  document.definitions.forEach(function (definition) {
214
247
  if (definition.kind === "OperationDefinition") {
215
248
  throw newInvariantError(
216
- 74,
249
+ 84,
217
250
  definition.operation,
218
251
  definition.name ? " named '".concat(definition.name.value, "'") : ""
219
252
  );
@@ -223,7 +256,7 @@ function getFragmentQueryDocument(document, fragmentName) {
223
256
  }
224
257
  });
225
258
  if (typeof actualFragmentName === "undefined") {
226
- invariant(fragments.length === 1, 75, fragments.length);
259
+ invariant(fragments.length === 1, 85, fragments.length);
227
260
  actualFragmentName = fragments[0].name.value;
228
261
  }
229
262
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -264,7 +297,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
264
297
  return fragmentMap(fragmentName);
265
298
  }
266
299
  var fragment = fragmentMap && fragmentMap[fragmentName];
267
- invariant(fragment, 76, fragmentName);
300
+ invariant(fragment, 86, fragmentName);
268
301
  return fragment || null;
269
302
  }
270
303
  default:
@@ -515,7 +548,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
515
548
  argObj[name.value] = null;
516
549
  }
517
550
  else {
518
- throw newInvariantError(85, name.value, value.kind);
551
+ throw newInvariantError(95, name.value, value.kind);
519
552
  }
520
553
  }
521
554
  function storeKeyNameFromField(field, variables) {
@@ -649,16 +682,16 @@ function isInlineFragment(selection) {
649
682
  }
650
683
 
651
684
  function checkDocument(doc) {
652
- invariant(doc && doc.kind === "Document", 77);
685
+ invariant(doc && doc.kind === "Document", 87);
653
686
  var operations = doc.definitions
654
687
  .filter(function (d) { return d.kind !== "FragmentDefinition"; })
655
688
  .map(function (definition) {
656
689
  if (definition.kind !== "OperationDefinition") {
657
- throw newInvariantError(78, definition.kind);
690
+ throw newInvariantError(88, definition.kind);
658
691
  }
659
692
  return definition;
660
693
  });
661
- invariant(operations.length <= 1, 79, operations.length);
694
+ invariant(operations.length <= 1, 89, operations.length);
662
695
  return doc;
663
696
  }
664
697
  function getOperationDefinition(doc) {
@@ -681,14 +714,14 @@ function getFragmentDefinitions(doc) {
681
714
  }
682
715
  function getQueryDefinition(doc) {
683
716
  var queryDef = getOperationDefinition(doc);
684
- invariant(queryDef && queryDef.operation === "query", 80);
717
+ invariant(queryDef && queryDef.operation === "query", 90);
685
718
  return queryDef;
686
719
  }
687
720
  function getFragmentDefinition(doc) {
688
- invariant(doc.kind === "Document", 81);
689
- invariant(doc.definitions.length <= 1, 82);
721
+ invariant(doc.kind === "Document", 91);
722
+ invariant(doc.definitions.length <= 1, 92);
690
723
  var fragmentDef = doc.definitions[0];
691
- invariant(fragmentDef.kind === "FragmentDefinition", 83);
724
+ invariant(fragmentDef.kind === "FragmentDefinition", 93);
692
725
  return fragmentDef;
693
726
  }
694
727
  function getMainDefinition(queryDoc) {
@@ -711,7 +744,7 @@ function getMainDefinition(queryDoc) {
711
744
  if (fragmentDefinition) {
712
745
  return fragmentDefinition;
713
746
  }
714
- throw newInvariantError(84);
747
+ throw newInvariantError(94);
715
748
  }
716
749
  function getDefaultValues(definition) {
717
750
  var defaultValues = Object.create(null);
@@ -762,7 +795,7 @@ var DocumentTransform = (function () {
762
795
  makeCacheKey: function (document) {
763
796
  var cacheKeys = _this.getCacheKey(document);
764
797
  if (cacheKeys) {
765
- invariant(Array.isArray(cacheKeys), 69);
798
+ invariant(Array.isArray(cacheKeys), 76);
766
799
  return stableCacheKeys_1.lookupArray(cacheKeys);
767
800
  }
768
801
  },
@@ -892,7 +925,7 @@ function removeDirectivesFromDocument(directives, doc) {
892
925
  return getInUseByFragmentName(ancestor.name.value);
893
926
  }
894
927
  }
895
- globalThis.__DEV__ !== false && invariant.error(86);
928
+ globalThis.__DEV__ !== false && invariant.error(96);
896
929
  return null;
897
930
  };
898
931
  var operationCount = 0;
@@ -1101,6 +1134,19 @@ function removeClientSetsFromDocument(document) {
1101
1134
  ], document);
1102
1135
  return modifiedDoc;
1103
1136
  }
1137
+ function addNonReactiveToNamedFragments(document) {
1138
+ checkDocument(document);
1139
+ return graphql.visit(document, {
1140
+ FragmentSpread: function (node) {
1141
+ return tslib.__assign(tslib.__assign({}, node), { directives: tslib.__spreadArray(tslib.__spreadArray([], (node.directives || []), true), [
1142
+ {
1143
+ kind: graphql.Kind.DIRECTIVE,
1144
+ name: { kind: graphql.Kind.NAME, value: "nonreactive" },
1145
+ },
1146
+ ], false) });
1147
+ },
1148
+ });
1149
+ }
1104
1150
 
1105
1151
  var hasOwnProperty$4 = Object.prototype.hasOwnProperty;
1106
1152
  function mergeDeep() {
@@ -1215,6 +1261,11 @@ function wrapPromiseWithState(promise) {
1215
1261
  return promise;
1216
1262
  }
1217
1263
 
1264
+ function preventUnhandledRejection(promise) {
1265
+ promise.catch(function () { });
1266
+ return promise;
1267
+ }
1268
+
1218
1269
  var toString = Object.prototype.toString;
1219
1270
  function cloneDeep(value) {
1220
1271
  return cloneDeepHelper(value);
@@ -1546,7 +1597,7 @@ function toPromise(observable) {
1546
1597
  observable.subscribe({
1547
1598
  next: function (data) {
1548
1599
  if (completed) {
1549
- globalThis.__DEV__ !== false && invariant.warn(43);
1600
+ globalThis.__DEV__ !== false && invariant.warn(50);
1550
1601
  }
1551
1602
  else {
1552
1603
  completed = true;
@@ -1589,7 +1640,7 @@ function validateOperation(operation) {
1589
1640
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
1590
1641
  var key = _a[_i];
1591
1642
  if (OPERATION_FIELDS.indexOf(key) < 0) {
1592
- throw newInvariantError(44, key);
1643
+ throw newInvariantError(51, key);
1593
1644
  }
1594
1645
  }
1595
1646
  return operation;
@@ -1698,7 +1749,7 @@ var ApolloLink = (function () {
1698
1749
  ApolloLink.concat = function (first, second) {
1699
1750
  var firstLink = toLink(first);
1700
1751
  if (isTerminating(firstLink)) {
1701
- globalThis.__DEV__ !== false && invariant.warn(36, firstLink);
1752
+ globalThis.__DEV__ !== false && invariant.warn(43, firstLink);
1702
1753
  return firstLink;
1703
1754
  }
1704
1755
  var nextLink = toLink(second);
@@ -1724,7 +1775,7 @@ var ApolloLink = (function () {
1724
1775
  return ApolloLink.concat(this, next);
1725
1776
  };
1726
1777
  ApolloLink.prototype.request = function (operation, forward) {
1727
- throw newInvariantError(37);
1778
+ throw newInvariantError(44);
1728
1779
  };
1729
1780
  ApolloLink.prototype.onError = function (error, observer) {
1730
1781
  if (observer && observer.error) {
@@ -2106,7 +2157,7 @@ var serializeFetchParameter = function (p, label) {
2106
2157
  serialized = JSON.stringify(p);
2107
2158
  }
2108
2159
  catch (e) {
2109
- var parseError = newInvariantError(40, label, e.message);
2160
+ var parseError = newInvariantError(47, label, e.message);
2110
2161
  parseError.parseError = e;
2111
2162
  throw parseError;
2112
2163
  }
@@ -2170,20 +2221,20 @@ function selectHttpOptionsAndBodyInternal(operation, printer) {
2170
2221
  }
2171
2222
  function removeDuplicateHeaders(headers, preserveHeaderCase) {
2172
2223
  if (!preserveHeaderCase) {
2173
- var normalizedHeaders_1 = Object.create(null);
2224
+ var normalizedHeaders_1 = {};
2174
2225
  Object.keys(Object(headers)).forEach(function (name) {
2175
2226
  normalizedHeaders_1[name.toLowerCase()] = headers[name];
2176
2227
  });
2177
2228
  return normalizedHeaders_1;
2178
2229
  }
2179
- var headerData = Object.create(null);
2230
+ var headerData = {};
2180
2231
  Object.keys(Object(headers)).forEach(function (name) {
2181
2232
  headerData[name.toLowerCase()] = {
2182
2233
  originalName: name,
2183
2234
  value: headers[name],
2184
2235
  };
2185
2236
  });
2186
- var normalizedHeaders = Object.create(null);
2237
+ var normalizedHeaders = {};
2187
2238
  Object.keys(headerData).forEach(function (name) {
2188
2239
  normalizedHeaders[headerData[name].originalName] = headerData[name].value;
2189
2240
  });
@@ -2192,7 +2243,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
2192
2243
 
2193
2244
  var checkFetcher = function (fetcher) {
2194
2245
  if (!fetcher && typeof fetch === "undefined") {
2195
- throw newInvariantError(38);
2246
+ throw newInvariantError(45);
2196
2247
  }
2197
2248
  };
2198
2249
 
@@ -2326,7 +2377,7 @@ var createHttpLink = function (linkOptions) {
2326
2377
  options.headers = options.headers || {};
2327
2378
  var acceptHeader = "multipart/mixed;";
2328
2379
  if (isSubscription && hasDefer) {
2329
- globalThis.__DEV__ !== false && invariant.warn(39);
2380
+ globalThis.__DEV__ !== false && invariant.warn(46);
2330
2381
  }
2331
2382
  if (isSubscription) {
2332
2383
  acceptHeader +=
@@ -2460,6 +2511,209 @@ function directiveIsNonreactive(dir) {
2460
2511
  return dir.name.value === "nonreactive";
2461
2512
  }
2462
2513
 
2514
+ function maskOperation(data, document, cache) {
2515
+ var _a;
2516
+ if (!cache.fragmentMatches) {
2517
+ if (globalThis.__DEV__ !== false) {
2518
+ warnOnImproperCacheImplementation();
2519
+ }
2520
+ return data;
2521
+ }
2522
+ var definition = getOperationDefinition(document);
2523
+ invariant(definition, 37);
2524
+ if (data == null) {
2525
+ return data;
2526
+ }
2527
+ var context = {
2528
+ operationType: definition.operation,
2529
+ operationName: (_a = definition.name) === null || _a === void 0 ? void 0 : _a.value,
2530
+ fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2531
+ cache: cache,
2532
+ };
2533
+ var _b = maskSelectionSet(data, definition.selectionSet, context), masked = _b[0], changed = _b[1];
2534
+ if (Object.isFrozen(data)) {
2535
+ context.disableWarnings = true;
2536
+ maybeDeepFreeze(masked);
2537
+ context.disableWarnings = false;
2538
+ }
2539
+ return changed ? masked : data;
2540
+ }
2541
+ function maskFragment(data, document, cache, fragmentName) {
2542
+ if (!cache.fragmentMatches) {
2543
+ if (globalThis.__DEV__ !== false) {
2544
+ warnOnImproperCacheImplementation();
2545
+ }
2546
+ return data;
2547
+ }
2548
+ var fragments = document.definitions.filter(function (node) {
2549
+ return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
2550
+ });
2551
+ if (typeof fragmentName === "undefined") {
2552
+ invariant(fragments.length === 1, 38, fragments.length);
2553
+ fragmentName = fragments[0].name.value;
2554
+ }
2555
+ var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
2556
+ invariant(!!fragment, 39, fragmentName);
2557
+ if (data == null) {
2558
+ return data;
2559
+ }
2560
+ var context = {
2561
+ operationType: "fragment",
2562
+ operationName: fragment.name.value,
2563
+ fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2564
+ cache: cache,
2565
+ };
2566
+ var _a = maskSelectionSet(data, fragment.selectionSet, context), masked = _a[0], changed = _a[1];
2567
+ if (Object.isFrozen(data)) {
2568
+ context.disableWarnings = true;
2569
+ maybeDeepFreeze(masked);
2570
+ context.disableWarnings = false;
2571
+ }
2572
+ return changed ? masked : data;
2573
+ }
2574
+ function maskSelectionSet(data, selectionSet, context, path) {
2575
+ if (Array.isArray(data)) {
2576
+ var changed_1 = false;
2577
+ var masked = data.map(function (item, index) {
2578
+ if (item === null) {
2579
+ return null;
2580
+ }
2581
+ var _a = maskSelectionSet(item, selectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0), masked = _a[0], itemChanged = _a[1];
2582
+ changed_1 || (changed_1 = itemChanged);
2583
+ return itemChanged ? masked : item;
2584
+ });
2585
+ return [changed_1 ? masked : data, changed_1];
2586
+ }
2587
+ var result = selectionSet.selections.reduce(function (_a, selection) {
2588
+ var memo = _a[0], changed = _a[1];
2589
+ switch (selection.kind) {
2590
+ case graphql.Kind.FIELD: {
2591
+ var keyName = resultKeyNameFromField(selection);
2592
+ var childSelectionSet = selection.selectionSet;
2593
+ memo[keyName] = data[keyName];
2594
+ if (childSelectionSet && data[keyName] !== null) {
2595
+ var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
2596
+ if (childChanged ||
2597
+ Object.keys(masked).length !== Object.keys(data[keyName]).length) {
2598
+ memo[keyName] = masked;
2599
+ changed = true;
2600
+ }
2601
+ }
2602
+ return [memo, changed];
2603
+ }
2604
+ case graphql.Kind.INLINE_FRAGMENT: {
2605
+ if (selection.typeCondition &&
2606
+ !context.cache.fragmentMatches(selection, data.__typename)) {
2607
+ return [memo, changed];
2608
+ }
2609
+ var _c = maskSelectionSet(data, selection.selectionSet, context, path), fragmentData = _c[0], childChanged = _c[1];
2610
+ return [
2611
+ tslib.__assign(tslib.__assign({}, memo), fragmentData),
2612
+ changed || childChanged,
2613
+ ];
2614
+ }
2615
+ case graphql.Kind.FRAGMENT_SPREAD: {
2616
+ var fragmentName = selection.name.value;
2617
+ var fragment = context.fragmentMap[fragmentName] ||
2618
+ (context.fragmentMap[fragmentName] =
2619
+ context.cache.lookupFragment(fragmentName));
2620
+ invariant(fragment, 40, fragmentName);
2621
+ var mode = getFragmentMaskMode(selection);
2622
+ if (mode === "mask") {
2623
+ return [memo, true];
2624
+ }
2625
+ if (globalThis.__DEV__ !== false) {
2626
+ if (mode === "migrate") {
2627
+ return [
2628
+ addFieldAccessorWarnings(memo, data, fragment.selectionSet, path || "", context),
2629
+ true,
2630
+ ];
2631
+ }
2632
+ }
2633
+ var _d = maskSelectionSet(data, fragment.selectionSet, context, path), fragmentData = _d[0], changed_2 = _d[1];
2634
+ return [tslib.__assign(tslib.__assign({}, memo), fragmentData), changed_2];
2635
+ }
2636
+ }
2637
+ }, [Object.create(null), false]);
2638
+ if ("__typename" in data && !("__typename" in result[0])) {
2639
+ result[0].__typename = data.__typename;
2640
+ }
2641
+ return result;
2642
+ }
2643
+ function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
2644
+ if (Array.isArray(data)) {
2645
+ return data.map(function (item, index) {
2646
+ return addFieldAccessorWarnings(memo[index] || Object.create(null), item, selectionSetNode, "".concat(path, "[").concat(index, "]"), context);
2647
+ });
2648
+ }
2649
+ return selectionSetNode.selections.reduce(function (memo, selection) {
2650
+ switch (selection.kind) {
2651
+ case graphql.Kind.FIELD: {
2652
+ var keyName = resultKeyNameFromField(selection);
2653
+ var childSelectionSet = selection.selectionSet;
2654
+ if (keyName in memo) {
2655
+ return memo;
2656
+ }
2657
+ var value = data[keyName];
2658
+ if (childSelectionSet) {
2659
+ value = addFieldAccessorWarnings(memo[keyName] || Object.create(null), data[keyName], childSelectionSet, "".concat(path, ".").concat(keyName), context);
2660
+ }
2661
+ if (globalThis.__DEV__ !== false) {
2662
+ addAccessorWarning(memo, value, keyName, path, context);
2663
+ }
2664
+ if (!(globalThis.__DEV__ !== false)) {
2665
+ memo[keyName] = data[keyName];
2666
+ }
2667
+ return memo;
2668
+ }
2669
+ case graphql.Kind.INLINE_FRAGMENT: {
2670
+ return addFieldAccessorWarnings(memo, data, selection.selectionSet, path, context);
2671
+ }
2672
+ case graphql.Kind.FRAGMENT_SPREAD: {
2673
+ var fragment = context.fragmentMap[selection.name.value];
2674
+ var mode = getFragmentMaskMode(selection);
2675
+ if (mode === "mask") {
2676
+ return memo;
2677
+ }
2678
+ if (mode === "unmask") {
2679
+ var fragmentData = maskSelectionSet(data, fragment.selectionSet, context, path)[0];
2680
+ return Object.assign(memo, fragmentData);
2681
+ }
2682
+ return addFieldAccessorWarnings(memo, data, fragment.selectionSet, path, context);
2683
+ }
2684
+ }
2685
+ }, memo);
2686
+ }
2687
+ function addAccessorWarning(data, value, fieldName, path, context) {
2688
+ var getValue = function () {
2689
+ if (context.disableWarnings) {
2690
+ return value;
2691
+ }
2692
+ globalThis.__DEV__ !== false && invariant.warn(41, context.operationName ?
2693
+ "".concat(context.operationType, " '").concat(context.operationName, "'")
2694
+ : "anonymous ".concat(context.operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
2695
+ getValue = function () { return value; };
2696
+ return value;
2697
+ };
2698
+ Object.defineProperty(data, fieldName, {
2699
+ get: function () {
2700
+ return getValue();
2701
+ },
2702
+ set: function (value) {
2703
+ getValue = function () { return value; };
2704
+ },
2705
+ enumerable: true,
2706
+ configurable: true,
2707
+ });
2708
+ }
2709
+ var issuedWarning = false;
2710
+ function warnOnImproperCacheImplementation() {
2711
+ if (!issuedWarning) {
2712
+ issuedWarning = true;
2713
+ globalThis.__DEV__ !== false && invariant.warn(42);
2714
+ }
2715
+ }
2716
+
2463
2717
  var ApolloCache = (function () {
2464
2718
  function ApolloCache() {
2465
2719
  this.assumeImmutableResults = false;
@@ -2469,6 +2723,9 @@ var ApolloCache = (function () {
2469
2723
  cache: caches.WeakCache,
2470
2724
  });
2471
2725
  }
2726
+ ApolloCache.prototype.lookupFragment = function (fragmentName) {
2727
+ return null;
2728
+ };
2472
2729
  ApolloCache.prototype.batch = function (options) {
2473
2730
  var _this = this;
2474
2731
  var optimisticId = typeof options.optimistic === "string" ? options.optimistic
@@ -2504,26 +2761,36 @@ var ApolloCache = (function () {
2504
2761
  var _this = this;
2505
2762
  var fragment = options.fragment, fragmentName = options.fragmentName, from = options.from, _a = options.optimistic, optimistic = _a === void 0 ? true : _a, otherOptions = tslib.__rest(options, ["fragment", "fragmentName", "from", "optimistic"]);
2506
2763
  var query = this.getFragmentDoc(fragment, fragmentName);
2507
- var diffOptions = tslib.__assign(tslib.__assign({}, otherOptions), { returnPartialData: true, id:
2508
- typeof from === "undefined" || typeof from === "string" ?
2509
- from
2510
- : this.identify(from), query: query, optimistic: optimistic });
2764
+ var id = typeof from === "undefined" || typeof from === "string" ?
2765
+ from
2766
+ : this.identify(from);
2767
+ var dataMasking = !!options[Symbol.for("apollo.dataMasking")];
2768
+ if (globalThis.__DEV__ !== false) {
2769
+ var actualFragmentName = fragmentName || getFragmentDefinition(fragment).name.value;
2770
+ if (!id) {
2771
+ globalThis.__DEV__ !== false && invariant.warn(1, actualFragmentName);
2772
+ }
2773
+ }
2774
+ var diffOptions = tslib.__assign(tslib.__assign({}, otherOptions), { returnPartialData: true, id: id, query: query, optimistic: optimistic });
2511
2775
  var latestDiff;
2512
2776
  return new zenObservableTs.Observable(function (observer) {
2513
2777
  return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
2778
+ var data = dataMasking ?
2779
+ maskFragment(diff.result, fragment, _this, fragmentName)
2780
+ : diff.result;
2514
2781
  if (
2515
2782
  latestDiff &&
2516
- equalByQuery(query, { data: latestDiff === null || latestDiff === void 0 ? void 0 : latestDiff.result }, { data: diff.result })) {
2783
+ equalByQuery(query, { data: latestDiff === null || latestDiff === void 0 ? void 0 : latestDiff.result }, { data: data })) {
2517
2784
  return;
2518
2785
  }
2519
2786
  var result = {
2520
- data: diff.result,
2787
+ data: data,
2521
2788
  complete: !!diff.complete,
2522
2789
  };
2523
2790
  if (diff.missing) {
2524
2791
  result.missing = mergeDeepArray(diff.missing.map(function (error) { return error.missing; }));
2525
2792
  }
2526
- latestDiff = diff;
2793
+ latestDiff = tslib.__assign(tslib.__assign({}, diff), { result: data });
2527
2794
  observer.next(result);
2528
2795
  } }));
2529
2796
  });
@@ -2773,7 +3040,7 @@ var EntityStore = (function () {
2773
3040
  var incoming = typeof newer === "string" ? this.lookup((dataId = newer)) : newer;
2774
3041
  if (!incoming)
2775
3042
  return;
2776
- invariant(typeof dataId === "string", 1);
3043
+ invariant(typeof dataId === "string", 2);
2777
3044
  var merged = new DeepMerger(storeObjectReconciler).merge(existing, incoming);
2778
3045
  this.data[dataId] = merged;
2779
3046
  if (merged !== existing) {
@@ -2850,7 +3117,7 @@ var EntityStore = (function () {
2850
3117
  if (globalThis.__DEV__ !== false) {
2851
3118
  var checkReference = function (ref) {
2852
3119
  if (_this.lookup(ref.__ref) === undefined) {
2853
- globalThis.__DEV__ !== false && invariant.warn(2, ref);
3120
+ globalThis.__DEV__ !== false && invariant.warn(3, ref);
2854
3121
  return true;
2855
3122
  }
2856
3123
  };
@@ -2876,7 +3143,7 @@ var EntityStore = (function () {
2876
3143
  }
2877
3144
  }
2878
3145
  if (seenReference && someNonReference !== undefined) {
2879
- globalThis.__DEV__ !== false && invariant.warn(3, someNonReference);
3146
+ globalThis.__DEV__ !== false && invariant.warn(4, someNonReference);
2880
3147
  break;
2881
3148
  }
2882
3149
  }
@@ -3459,7 +3726,7 @@ var StoreReader = (function () {
3459
3726
  else {
3460
3727
  var fragment = getFragmentFromSelection(selection, context.lookupFragment);
3461
3728
  if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
3462
- throw newInvariantError(9, selection.name.value);
3729
+ throw newInvariantError(10, selection.name.value);
3463
3730
  }
3464
3731
  if (fragment && policies.fragmentMatches(fragment, typename)) {
3465
3732
  fragment.selectionSet.selections.forEach(workSet.add, workSet);
@@ -3542,7 +3809,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
3542
3809
  if (isNonNullObject(value)) {
3543
3810
  invariant(
3544
3811
  !isReference(value),
3545
- 10,
3812
+ 11,
3546
3813
  getTypenameFromStoreObject(store, value),
3547
3814
  field.name.value
3548
3815
  );
@@ -3635,7 +3902,7 @@ function keyFieldsFnFromSpecifier(specifier) {
3635
3902
  hasOwn.call(object, schemaKeyPath[0])) {
3636
3903
  extracted = extractKeyPath(object, schemaKeyPath, extractKey);
3637
3904
  }
3638
- invariant(extracted !== void 0, 4, schemaKeyPath.join("."), object);
3905
+ invariant(extracted !== void 0, 5, schemaKeyPath.join("."), object);
3639
3906
  return extracted;
3640
3907
  }));
3641
3908
  return "".concat(context.typename, ":").concat(JSON.stringify(keyObject));
@@ -3871,7 +4138,7 @@ var Policies = (function () {
3871
4138
  var rootId = "ROOT_" + which.toUpperCase();
3872
4139
  var old = this.rootTypenamesById[rootId];
3873
4140
  if (typename !== old) {
3874
- invariant(!old || old === which, 5, which);
4141
+ invariant(!old || old === which, 6, which);
3875
4142
  if (old)
3876
4143
  delete this.rootIdsByTypename[old];
3877
4144
  this.rootIdsByTypename[typename] = rootId;
@@ -3968,7 +4235,7 @@ var Policies = (function () {
3968
4235
  if (supertypeSet.has(supertype)) {
3969
4236
  if (!typenameSupertypeSet.has(supertype)) {
3970
4237
  if (checkingFuzzySubtypes) {
3971
- globalThis.__DEV__ !== false && invariant.warn(6, typename, supertype);
4238
+ globalThis.__DEV__ !== false && invariant.warn(7, typename, supertype);
3972
4239
  }
3973
4240
  typenameSupertypeSet.add(supertype);
3974
4241
  }
@@ -4131,7 +4398,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
4131
4398
  }
4132
4399
  }
4133
4400
  if (globalThis.__DEV__ !== false && options.from === void 0) {
4134
- globalThis.__DEV__ !== false && invariant.warn(7, stringifyForDisplay(Array.from(readFieldArgs)));
4401
+ globalThis.__DEV__ !== false && invariant.warn(8, stringifyForDisplay(Array.from(readFieldArgs)));
4135
4402
  }
4136
4403
  if (void 0 === options.variables) {
4137
4404
  options.variables = variables;
@@ -4141,7 +4408,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
4141
4408
  function makeMergeObjectsFunction(store) {
4142
4409
  return function mergeObjects(existing, incoming) {
4143
4410
  if (isArray(existing) || isArray(incoming)) {
4144
- throw newInvariantError(8);
4411
+ throw newInvariantError(9);
4145
4412
  }
4146
4413
  if (isNonNullObject(existing) && isNonNullObject(incoming)) {
4147
4414
  var eType = store.getFieldValue(existing, "__typename");
@@ -4201,7 +4468,7 @@ var StoreWriter = (function () {
4201
4468
  context: context,
4202
4469
  });
4203
4470
  if (!isReference(ref)) {
4204
- throw newInvariantError(11, result);
4471
+ throw newInvariantError(12, result);
4205
4472
  }
4206
4473
  context.incomingById.forEach(function (_a, dataId) {
4207
4474
  var storeObject = _a.storeObject, mergeTree = _a.mergeTree, fieldNodeSet = _a.fieldNodeSet;
@@ -4309,7 +4576,7 @@ var StoreWriter = (function () {
4309
4576
  !context.deferred &&
4310
4577
  !addTypenameToDocument.added(field) &&
4311
4578
  !policies.getReadFunction(typename, field.name.value)) {
4312
- globalThis.__DEV__ !== false && invariant.error(12, resultKeyNameFromField(field), result);
4579
+ globalThis.__DEV__ !== false && invariant.error(13, resultKeyNameFromField(field), result);
4313
4580
  }
4314
4581
  });
4315
4582
  try {
@@ -4416,7 +4683,7 @@ var StoreWriter = (function () {
4416
4683
  else {
4417
4684
  var fragment = getFragmentFromSelection(selection, context.lookupFragment);
4418
4685
  if (!fragment && selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
4419
- throw newInvariantError(13, selection.name.value);
4686
+ throw newInvariantError(14, selection.name.value);
4420
4687
  }
4421
4688
  if (fragment &&
4422
4689
  policies.fragmentMatches(fragment, typename, result, context.variables)) {
@@ -4556,7 +4823,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
4556
4823
  }
4557
4824
  });
4558
4825
  }
4559
- globalThis.__DEV__ !== false && invariant.warn(14, fieldName, parentType, childTypenames.length ?
4826
+ globalThis.__DEV__ !== false && invariant.warn(15, fieldName, parentType, childTypenames.length ?
4560
4827
  "either ensure all objects of type " +
4561
4828
  childTypenames.join(" and ") +
4562
4829
  " have an ID or a custom merge function, or "
@@ -4830,6 +5097,13 @@ var InMemoryCache = (function (_super) {
4830
5097
  InMemoryCache.prototype.transformDocument = function (document) {
4831
5098
  return this.addTypenameToDocument(this.addFragmentsToDocument(document));
4832
5099
  };
5100
+ InMemoryCache.prototype.fragmentMatches = function (fragment, typename) {
5101
+ return this.policies.fragmentMatches(fragment, typename);
5102
+ };
5103
+ InMemoryCache.prototype.lookupFragment = function (fragmentName) {
5104
+ var _a;
5105
+ return ((_a = this.config.fragments) === null || _a === void 0 ? void 0 : _a.lookup(fragmentName)) || null;
5106
+ };
4833
5107
  InMemoryCache.prototype.broadcastWatches = function (options) {
4834
5108
  var _this = this;
4835
5109
  if (!this.txCount) {
@@ -4905,7 +5179,7 @@ var ObservableQuery = (function (_super) {
4905
5179
  observer.error && observer.error(last.error);
4906
5180
  }
4907
5181
  else if (last && last.result) {
4908
- observer.next && observer.next(last.result);
5182
+ observer.next && observer.next(_this.maskResult(last.result));
4909
5183
  }
4910
5184
  if (first) {
4911
5185
  _this.reobserve().catch(function () { });
@@ -4923,6 +5197,7 @@ var ObservableQuery = (function (_super) {
4923
5197
  _this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);
4924
5198
  _this.isTornDown = false;
4925
5199
  _this.subscribeToMore = _this.subscribeToMore.bind(_this);
5200
+ _this.maskResult = _this.maskResult.bind(_this);
4926
5201
  var _b = queryManager.defaultOptions.watchQuery, _c = _b === void 0 ? {} : _b, _d = _c.fetchPolicy, defaultFetchPolicy = _d === void 0 ? "cache-first" : _d;
4927
5202
  var _e = options.fetchPolicy, fetchPolicy = _e === void 0 ? defaultFetchPolicy : _e,
4928
5203
  _f = options.initialFetchPolicy,
@@ -4971,7 +5246,7 @@ var ObservableQuery = (function (_super) {
4971
5246
  ObservableQuery.prototype.resetDiff = function () {
4972
5247
  this.queryInfo.resetDiff();
4973
5248
  };
4974
- ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
5249
+ ObservableQuery.prototype.getCurrentFullResult = function (saveAsLastResult) {
4975
5250
  if (saveAsLastResult === void 0) { saveAsLastResult = true; }
4976
5251
  var lastResult = this.getLastResult(true);
4977
5252
  var networkStatus = this.queryInfo.networkStatus ||
@@ -5019,12 +5294,19 @@ var ObservableQuery = (function (_super) {
5019
5294
  }
5020
5295
  return result;
5021
5296
  };
5297
+ ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
5298
+ if (saveAsLastResult === void 0) { saveAsLastResult = true; }
5299
+ return this.maskResult(this.getCurrentFullResult(saveAsLastResult));
5300
+ };
5022
5301
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
5023
5302
  if (!this.last) {
5024
5303
  return true;
5025
5304
  }
5026
- var resultIsDifferent = this.queryManager.getDocumentInfo(this.query).hasNonreactiveDirective ?
5027
- !equalByQuery(this.query, this.last.result, newResult, this.variables)
5305
+ var documentInfo = this.queryManager.getDocumentInfo(this.query);
5306
+ var dataMasking = this.queryManager.dataMasking;
5307
+ var query = dataMasking ? documentInfo.nonReactiveQuery : this.query;
5308
+ var resultIsDifferent = dataMasking || documentInfo.hasNonreactiveDirective ?
5309
+ !equalByQuery(query, this.last.result, newResult, this.variables)
5028
5310
  : !equal.equal(this.last.result, newResult);
5029
5311
  return (resultIsDifferent || (variables && !equal.equal(this.last.variables, variables)));
5030
5312
  };
@@ -5069,7 +5351,7 @@ var ObservableQuery = (function (_super) {
5069
5351
  var vars = queryDef.variableDefinitions;
5070
5352
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
5071
5353
  globalThis.__DEV__ !== false && invariant.warn(
5072
- 20,
5354
+ 21,
5073
5355
  variables,
5074
5356
  ((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
5075
5357
  );
@@ -5101,7 +5383,7 @@ var ObservableQuery = (function (_super) {
5101
5383
  var updateQuery = fetchMoreOptions === null || fetchMoreOptions === void 0 ? void 0 : fetchMoreOptions.updateQuery;
5102
5384
  var isCached = this.options.fetchPolicy !== "no-cache";
5103
5385
  if (!isCached) {
5104
- invariant(updateQuery, 21);
5386
+ invariant(updateQuery, 22);
5105
5387
  }
5106
5388
  return this.queryManager
5107
5389
  .fetchQuery(qid, combinedOptions, exports.NetworkStatus.fetchMore)
@@ -5148,7 +5430,7 @@ var ObservableQuery = (function (_super) {
5148
5430
  });
5149
5431
  _this.reportResult(tslib.__assign(tslib.__assign({}, lastResult), { data: data }), _this.variables);
5150
5432
  }
5151
- return fetchMoreResult;
5433
+ return _this.maskResult(fetchMoreResult);
5152
5434
  })
5153
5435
  .finally(function () {
5154
5436
  if (isCached && !updatedQuerySet.has(_this.query)) {
@@ -5182,7 +5464,7 @@ var ObservableQuery = (function (_super) {
5182
5464
  options.onError(err);
5183
5465
  return;
5184
5466
  }
5185
- globalThis.__DEV__ !== false && invariant.error(22, err);
5467
+ globalThis.__DEV__ !== false && invariant.error(23, err);
5186
5468
  },
5187
5469
  });
5188
5470
  this.subscriptions.add(subscription);
@@ -5282,7 +5564,7 @@ var ObservableQuery = (function (_super) {
5282
5564
  if (pollingInfo && pollingInfo.interval === pollInterval) {
5283
5565
  return;
5284
5566
  }
5285
- invariant(pollInterval, 23);
5567
+ invariant(pollInterval, 24);
5286
5568
  var info = pollingInfo || (this.pollingInfo = {});
5287
5569
  info.interval = pollInterval;
5288
5570
  var maybeFetch = function () {
@@ -5385,8 +5667,7 @@ var ObservableQuery = (function (_super) {
5385
5667
  return concast;
5386
5668
  };
5387
5669
  ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
5388
- return this.reobserveAsConcast(newOptions, newNetworkStatus)
5389
- .promise;
5670
+ return preventUnhandledRejection(this.reobserveAsConcast(newOptions, newNetworkStatus).promise.then(this.maskResult));
5390
5671
  };
5391
5672
  ObservableQuery.prototype.resubscribeAfterError = function () {
5392
5673
  var args = [];
@@ -5401,7 +5682,7 @@ var ObservableQuery = (function (_super) {
5401
5682
  };
5402
5683
  ObservableQuery.prototype.observe = function () {
5403
5684
  this.reportResult(
5404
- this.getCurrentResult(false), this.variables);
5685
+ this.getCurrentFullResult(false), this.variables);
5405
5686
  };
5406
5687
  ObservableQuery.prototype.reportResult = function (result, variables) {
5407
5688
  var lastError = this.getLastError();
@@ -5410,7 +5691,7 @@ var ObservableQuery = (function (_super) {
5410
5691
  this.updateLastResult(result, variables);
5411
5692
  }
5412
5693
  if (lastError || isDifferent) {
5413
- iterateObserversSafely(this.observers, "next", result);
5694
+ iterateObserversSafely(this.observers, "next", this.maskResult(result));
5414
5695
  }
5415
5696
  };
5416
5697
  ObservableQuery.prototype.reportError = function (error, variables) {
@@ -5439,6 +5720,12 @@ var ObservableQuery = (function (_super) {
5439
5720
  ObservableQuery.prototype.transformDocument = function (document) {
5440
5721
  return this.queryManager.transform(document);
5441
5722
  };
5723
+ ObservableQuery.prototype.maskResult = function (result) {
5724
+ return result && "data" in result ? tslib.__assign(tslib.__assign({}, result), { data: this.queryManager.maskOperation({
5725
+ document: this.query,
5726
+ data: result.data,
5727
+ }) }) : result;
5728
+ };
5442
5729
  return ObservableQuery;
5443
5730
  }(zenObservableTs.Observable));
5444
5731
  fixObservableSubclass(ObservableQuery);
@@ -5459,11 +5746,11 @@ function reobserveCacheFirst(obsQuery) {
5459
5746
  return obsQuery.reobserve();
5460
5747
  }
5461
5748
  function defaultSubscriptionObserverErrorCallback(error) {
5462
- globalThis.__DEV__ !== false && invariant.error(24, error.message, error.stack);
5749
+ globalThis.__DEV__ !== false && invariant.error(25, error.message, error.stack);
5463
5750
  }
5464
5751
  function logMissingFieldErrors(missing) {
5465
5752
  if (globalThis.__DEV__ !== false && missing) {
5466
- globalThis.__DEV__ !== false && invariant.debug(25, missing);
5753
+ globalThis.__DEV__ !== false && invariant.debug(26, missing);
5467
5754
  }
5468
5755
  }
5469
5756
  function skipCacheDataFor(fetchPolicy ) {
@@ -5774,6 +6061,7 @@ var QueryManager = (function () {
5774
6061
  this.localState = options.localState;
5775
6062
  this.ssrMode = options.ssrMode;
5776
6063
  this.assumeImmutableResults = options.assumeImmutableResults;
6064
+ this.dataMasking = options.dataMasking;
5777
6065
  var documentTransform = options.documentTransform;
5778
6066
  this.documentTransform =
5779
6067
  documentTransform ?
@@ -5791,7 +6079,7 @@ var QueryManager = (function () {
5791
6079
  this.queries.forEach(function (_info, queryId) {
5792
6080
  _this.stopQueryNoBroadcast(queryId);
5793
6081
  });
5794
- this.cancelPendingFetches(newInvariantError(26));
6082
+ this.cancelPendingFetches(newInvariantError(27));
5795
6083
  };
5796
6084
  QueryManager.prototype.cancelPendingFetches = function (error) {
5797
6085
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -5805,8 +6093,8 @@ var QueryManager = (function () {
5805
6093
  return tslib.__generator(this, function (_j) {
5806
6094
  switch (_j.label) {
5807
6095
  case 0:
5808
- invariant(mutation, 27);
5809
- invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 28);
6096
+ invariant(mutation, 28);
6097
+ invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 29);
5810
6098
  mutationId = this.generateMutationId();
5811
6099
  mutation = this.cache.transformForLink(this.transform(mutation));
5812
6100
  hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
@@ -5876,7 +6164,10 @@ var QueryManager = (function () {
5876
6164
  next: function (storeResult) {
5877
6165
  self.broadcastQueries();
5878
6166
  if (!("hasNext" in storeResult) || storeResult.hasNext === false) {
5879
- resolve(storeResult);
6167
+ resolve(tslib.__assign(tslib.__assign({}, storeResult), { data: self.maskOperation({
6168
+ document: mutation,
6169
+ data: storeResult.data,
6170
+ }) }));
5880
6171
  }
5881
6172
  },
5882
6173
  error: function (err) {
@@ -6082,11 +6373,13 @@ var QueryManager = (function () {
6082
6373
  hasClientExports: hasClientExports(document),
6083
6374
  hasForcedResolvers: this.localState.shouldForceResolvers(document),
6084
6375
  hasNonreactiveDirective: hasDirectives(["nonreactive"], document),
6376
+ nonReactiveQuery: addNonReactiveToNamedFragments(document),
6085
6377
  clientQuery: this.localState.clientQuery(document),
6086
6378
  serverQuery: removeDirectivesFromDocument([
6087
6379
  { name: "client", remove: true },
6088
6380
  { name: "connection" },
6089
6381
  { name: "nonreactive" },
6382
+ { name: "unmask" },
6090
6383
  ], document),
6091
6384
  defaultVars: getDefaultValues(getOperationDefinition(document)),
6092
6385
  asQuery: tslib.__assign(tslib.__assign({}, document), { definitions: document.definitions.map(function (def) {
@@ -6128,11 +6421,16 @@ var QueryManager = (function () {
6128
6421
  QueryManager.prototype.query = function (options, queryId) {
6129
6422
  var _this = this;
6130
6423
  if (queryId === void 0) { queryId = this.generateQueryId(); }
6131
- invariant(options.query, 29);
6132
- invariant(options.query.kind === "Document", 30);
6133
- invariant(!options.returnPartialData, 31);
6134
- invariant(!options.pollInterval, 32);
6135
- return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
6424
+ invariant(options.query, 30);
6425
+ invariant(options.query.kind === "Document", 31);
6426
+ invariant(!options.returnPartialData, 32);
6427
+ invariant(!options.pollInterval, 33);
6428
+ var query = this.transform(options.query);
6429
+ return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: query }))
6430
+ .then(function (result) {
6431
+ return result && tslib.__assign(tslib.__assign({}, result), { data: _this.maskOperation({ document: query, data: result.data }) });
6432
+ })
6433
+ .finally(function () { return _this.stopQuery(queryId); });
6136
6434
  };
6137
6435
  QueryManager.prototype.generateQueryId = function () {
6138
6436
  return String(this.queryIdCounter++);
@@ -6156,7 +6454,7 @@ var QueryManager = (function () {
6156
6454
  if (options === void 0) { options = {
6157
6455
  discardWatches: true,
6158
6456
  }; }
6159
- this.cancelPendingFetches(newInvariantError(33));
6457
+ this.cancelPendingFetches(newInvariantError(34));
6160
6458
  this.queries.forEach(function (queryInfo) {
6161
6459
  if (queryInfo.observableQuery) {
6162
6460
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -6232,7 +6530,7 @@ var QueryManager = (function () {
6232
6530
  if (globalThis.__DEV__ !== false && queryNamesAndDocs.size) {
6233
6531
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
6234
6532
  if (!included) {
6235
- globalThis.__DEV__ !== false && invariant.warn(typeof nameOrDoc === "string" ? 34 : 35, nameOrDoc);
6533
+ globalThis.__DEV__ !== false && invariant.warn(typeof nameOrDoc === "string" ? 35 : 36, nameOrDoc);
6236
6534
  }
6237
6535
  });
6238
6536
  }
@@ -6257,9 +6555,10 @@ var QueryManager = (function () {
6257
6555
  QueryManager.prototype.setObservableQuery = function (observableQuery) {
6258
6556
  this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
6259
6557
  };
6260
- QueryManager.prototype.startGraphQLSubscription = function (_a) {
6558
+ QueryManager.prototype.startGraphQLSubscription = function (options) {
6261
6559
  var _this = this;
6262
- var query = _a.query, fetchPolicy = _a.fetchPolicy, _b = _a.errorPolicy, errorPolicy = _b === void 0 ? "none" : _b, variables = _a.variables, _c = _a.context, context = _c === void 0 ? {} : _c, _d = _a.extensions, extensions = _d === void 0 ? {} : _d;
6560
+ var query = options.query, variables = options.variables;
6561
+ var fetchPolicy = options.fetchPolicy, _a = options.errorPolicy, errorPolicy = _a === void 0 ? "none" : _a, _b = options.context, context = _b === void 0 ? {} : _b, _c = options.extensions, extensions = _c === void 0 ? {} : _c;
6263
6562
  query = this.transform(query);
6264
6563
  variables = this.getVariables(query, variables);
6265
6564
  var makeObservable = function (variables) {
@@ -6541,6 +6840,18 @@ var QueryManager = (function () {
6541
6840
  }
6542
6841
  return results;
6543
6842
  };
6843
+ QueryManager.prototype.maskOperation = function (options) {
6844
+ var document = options.document, data = options.data;
6845
+ return (this.dataMasking ?
6846
+ maskOperation(data, document, this.cache)
6847
+ : data);
6848
+ };
6849
+ QueryManager.prototype.maskFragment = function (options) {
6850
+ var data = options.data, fragment = options.fragment, fragmentName = options.fragmentName;
6851
+ return this.dataMasking ?
6852
+ maskFragment(data, fragment, this.cache, fragmentName)
6853
+ : data;
6854
+ };
6544
6855
  QueryManager.prototype.fetchQueryByPolicy = function (queryInfo, _a,
6545
6856
  networkStatus) {
6546
6857
  var _this = this;
@@ -6841,7 +7152,7 @@ var LocalState = (function () {
6841
7152
  }
6842
7153
  else {
6843
7154
  fragment = fragmentMap[selection.name.value];
6844
- invariant(fragment, 18, selection.name.value);
7155
+ invariant(fragment, 19, selection.name.value);
6845
7156
  }
6846
7157
  if (fragment && fragment.typeCondition) {
6847
7158
  typeCondition = fragment.typeCondition.name.value;
@@ -6955,7 +7266,7 @@ var LocalState = (function () {
6955
7266
  },
6956
7267
  FragmentSpread: function (spread, _, __, ___, ancestors) {
6957
7268
  var fragment = fragmentMap[spread.name.value];
6958
- invariant(fragment, 19, spread.name.value);
7269
+ invariant(fragment, 20, spread.name.value);
6959
7270
  var fragmentSelections = collectByDefinition(fragment);
6960
7271
  if (fragmentSelections.size > 0) {
6961
7272
  ancestors.forEach(function (node) {
@@ -6985,10 +7296,10 @@ var ApolloClient = (function () {
6985
7296
  this.resetStoreCallbacks = [];
6986
7297
  this.clearStoreCallbacks = [];
6987
7298
  if (!options.cache) {
6988
- throw newInvariantError(15);
7299
+ throw newInvariantError(16);
6989
7300
  }
6990
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,
6991
- 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;
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;
6992
7303
  var link = options.link;
6993
7304
  if (!link) {
6994
7305
  link =
@@ -7028,6 +7339,7 @@ var ApolloClient = (function () {
7028
7339
  documentTransform: documentTransform,
7029
7340
  queryDeduplication: queryDeduplication,
7030
7341
  ssrMode: ssrMode,
7342
+ dataMasking: !!dataMasking,
7031
7343
  clientAwareness: {
7032
7344
  name: clientAwarenessName,
7033
7345
  version: clientAwarenessVersion,
@@ -7116,7 +7428,7 @@ var ApolloClient = (function () {
7116
7428
  if (this.defaultOptions.query) {
7117
7429
  options = mergeOptions(this.defaultOptions.query, options);
7118
7430
  }
7119
- invariant(options.fetchPolicy !== "cache-and-network", 16);
7431
+ invariant(options.fetchPolicy !== "cache-and-network", 17);
7120
7432
  if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
7121
7433
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
7122
7434
  }
@@ -7129,14 +7441,21 @@ var ApolloClient = (function () {
7129
7441
  return this.queryManager.mutate(options);
7130
7442
  };
7131
7443
  ApolloClient.prototype.subscribe = function (options) {
7132
- return this.queryManager.startGraphQLSubscription(options);
7444
+ var _this = this;
7445
+ return this.queryManager
7446
+ .startGraphQLSubscription(options)
7447
+ .map(function (result) { return (tslib.__assign(tslib.__assign({}, result), { data: _this.queryManager.maskOperation({
7448
+ document: options.query,
7449
+ data: result.data,
7450
+ }) })); });
7133
7451
  };
7134
7452
  ApolloClient.prototype.readQuery = function (options, optimistic) {
7135
7453
  if (optimistic === void 0) { optimistic = false; }
7136
7454
  return this.cache.readQuery(options, optimistic);
7137
7455
  };
7138
7456
  ApolloClient.prototype.watchFragment = function (options) {
7139
- return this.cache.watchFragment(options);
7457
+ var _a;
7458
+ return this.cache.watchFragment(tslib.__assign(tslib.__assign({}, options), (_a = {}, _a[Symbol.for("apollo.dataMasking")] = this.queryManager.dataMasking, _a)));
7140
7459
  };
7141
7460
  ApolloClient.prototype.readFragment = function (options, optimistic) {
7142
7461
  if (optimistic === void 0) { optimistic = false; }
@@ -7212,7 +7531,7 @@ var ApolloClient = (function () {
7212
7531
  result.queries = queries;
7213
7532
  result.results = results;
7214
7533
  result.catch(function (error) {
7215
- globalThis.__DEV__ !== false && invariant.debug(17, error);
7534
+ globalThis.__DEV__ !== false && invariant.debug(18, error);
7216
7535
  });
7217
7536
  return result;
7218
7537
  };
@@ -7256,7 +7575,7 @@ if (globalThis.__DEV__ !== false) {
7256
7575
 
7257
7576
  var contextKey = canUseSymbol ? Symbol.for("__APOLLO_CONTEXT__") : "__APOLLO_CONTEXT__";
7258
7577
  function getApolloContext() {
7259
- invariant("createContext" in React__namespace, 46);
7578
+ invariant("createContext" in React__namespace, 53);
7260
7579
  var context = React__namespace.createContext[contextKey];
7261
7580
  if (!context) {
7262
7581
  Object.defineProperty(React__namespace.createContext, contextKey, {
@@ -7274,7 +7593,7 @@ var resetApolloContext = getApolloContext;
7274
7593
  var ApolloConsumer = function (props) {
7275
7594
  var ApolloContext = getApolloContext();
7276
7595
  return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
7277
- invariant(context && context.client, 45);
7596
+ invariant(context && context.client, 52);
7278
7597
  return props.children(context.client);
7279
7598
  }));
7280
7599
  };
@@ -7286,14 +7605,14 @@ var ApolloProvider = function (_a) {
7286
7605
  var context = React__namespace.useMemo(function () {
7287
7606
  return tslib.__assign(tslib.__assign({}, parentContext), { client: client || parentContext.client });
7288
7607
  }, [parentContext, client]);
7289
- invariant(context.client, 47);
7608
+ invariant(context.client, 54);
7290
7609
  return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
7291
7610
  };
7292
7611
 
7293
7612
  function useApolloClient(override) {
7294
7613
  var context = React__namespace.useContext(getApolloContext());
7295
7614
  var client = override || context.client;
7296
- invariant(!!client, 50);
7615
+ invariant(!!client, 57);
7297
7616
  return client;
7298
7617
  }
7299
7618
 
@@ -7308,7 +7627,7 @@ var useSyncExternalStore = realHook$1 ||
7308
7627
  !didWarnUncachedGetSnapshot &&
7309
7628
  value !== getSnapshot()) {
7310
7629
  didWarnUncachedGetSnapshot = true;
7311
- globalThis.__DEV__ !== false && invariant.error(60);
7630
+ globalThis.__DEV__ !== false && invariant.error(67);
7312
7631
  }
7313
7632
  var _a = React__namespace.useState({
7314
7633
  inst: { value: value, getSnapshot: getSnapshot },
@@ -7376,7 +7695,7 @@ function parser(document) {
7376
7695
  if (cached)
7377
7696
  return cached;
7378
7697
  var variables, type, name;
7379
- invariant(!!document && !!document.kind, 62, document);
7698
+ invariant(!!document && !!document.kind, 69, document);
7380
7699
  var fragments = [];
7381
7700
  var queries = [];
7382
7701
  var mutations = [];
@@ -7404,10 +7723,10 @@ function parser(document) {
7404
7723
  invariant(!fragments.length ||
7405
7724
  queries.length ||
7406
7725
  mutations.length ||
7407
- subscriptions.length, 63);
7726
+ subscriptions.length, 70);
7408
7727
  invariant(
7409
7728
  queries.length + mutations.length + subscriptions.length <= 1,
7410
- 64,
7729
+ 71,
7411
7730
  document,
7412
7731
  queries.length,
7413
7732
  subscriptions.length,
@@ -7419,7 +7738,7 @@ function parser(document) {
7419
7738
  var definitions = queries.length ? queries
7420
7739
  : mutations.length ? mutations
7421
7740
  : subscriptions;
7422
- invariant(definitions.length === 1, 65, document, definitions.length);
7741
+ invariant(definitions.length === 1, 72, document, definitions.length);
7423
7742
  var definition = definitions[0];
7424
7743
  variables = definition.variableDefinitions || [];
7425
7744
  if (definition.name && definition.name.kind === "Name") {
@@ -7444,7 +7763,7 @@ function verifyDocumentType(document, type) {
7444
7763
  var usedOperationName = operationName(operation.type);
7445
7764
  invariant(
7446
7765
  operation.type === type,
7447
- 66,
7766
+ 73,
7448
7767
  requiredOperationName,
7449
7768
  requiredOperationName,
7450
7769
  usedOperationName
@@ -7627,7 +7946,8 @@ function useObservableSubscriptionResult(resultData, observable, client, options
7627
7946
  (previousResult && previousResult.loading) ||
7628
7947
  !equal.equal(error, previousResult.error)) {
7629
7948
  setResult({
7630
- data: (previousResult && previousResult.data),
7949
+ data: (previousResult &&
7950
+ previousResult.data),
7631
7951
  error: error,
7632
7952
  loading: false,
7633
7953
  networkStatus: exports.NetworkStatus.error,
@@ -7891,7 +8211,7 @@ function executeQuery(resultData, observable, client, currentQuery, options, onQ
7891
8211
  resolve(toQueryResult(observable.getCurrentResult(), resultData.previousData, observable, client));
7892
8212
  },
7893
8213
  complete: function () {
7894
- resolve(toQueryResult(result, resultData.previousData, observable, client));
8214
+ resolve(toQueryResult(observable["maskResult"](result), resultData.previousData, observable, client));
7895
8215
  },
7896
8216
  });
7897
8217
  });
@@ -8016,10 +8336,10 @@ function useSubscription(subscription, options) {
8016
8336
  if (!hasIssuedDeprecationWarningRef.current) {
8017
8337
  hasIssuedDeprecationWarningRef.current = true;
8018
8338
  if (options.onSubscriptionData) {
8019
- globalThis.__DEV__ !== false && invariant.warn(options.onData ? 53 : 54);
8339
+ globalThis.__DEV__ !== false && invariant.warn(options.onData ? 60 : 61);
8020
8340
  }
8021
8341
  if (options.onSubscriptionComplete) {
8022
- globalThis.__DEV__ !== false && invariant.warn(options.onComplete ? 55 : 56);
8342
+ globalThis.__DEV__ !== false && invariant.warn(options.onComplete ? 62 : 63);
8023
8343
  }
8024
8344
  }
8025
8345
  var skip = options.skip, fetchPolicy = options.fetchPolicy, errorPolicy = options.errorPolicy, shouldResubscribe = options.shouldResubscribe, context = options.context, extensions = options.extensions, ignoreResults = options.ignoreResults;
@@ -8140,7 +8460,7 @@ function useSubscription(subscription, options) {
8140
8460
  : fallbackResult;
8141
8461
  }, function () { return fallbackResult; });
8142
8462
  var restart = React__namespace.useCallback(function () {
8143
- invariant(!optionsRef.current.skip, 57);
8463
+ invariant(!optionsRef.current.skip, 64);
8144
8464
  setObservable(recreateRef.current());
8145
8465
  }, [optionsRef, recreateRef]);
8146
8466
  return React__namespace.useMemo(function () { return (tslib.__assign(tslib.__assign({}, ret), { restart: restart })); }, [ret, restart]);
@@ -8187,20 +8507,27 @@ function useFragment(options) {
8187
8507
  return wrapHook("useFragment", _useFragment, useApolloClient(options.client))(options);
8188
8508
  }
8189
8509
  function _useFragment(options) {
8190
- var cache = useApolloClient(options.client).cache;
8510
+ var client = useApolloClient(options.client);
8511
+ var cache = client.cache;
8191
8512
  var from = options.from, rest = tslib.__rest(options, ["from"]);
8192
8513
  var id = React__namespace.useMemo(function () { return (typeof from === "string" ? from : cache.identify(from)); }, [cache, from]);
8193
8514
  var stableOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, rest), { from: id })); }, [rest, id]);
8194
8515
  var diff = React__namespace.useMemo(function () {
8195
8516
  var fragment = stableOptions.fragment, fragmentName = stableOptions.fragmentName, from = stableOptions.from, _a = stableOptions.optimistic, optimistic = _a === void 0 ? true : _a;
8517
+ var cache = client.cache;
8518
+ var diff = cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }));
8196
8519
  return {
8197
- result: diffToResult(cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }))),
8520
+ result: diffToResult(tslib.__assign(tslib.__assign({}, diff), { result: client["queryManager"].maskFragment({
8521
+ fragment: fragment,
8522
+ fragmentName: fragmentName,
8523
+ data: diff.result,
8524
+ }) })),
8198
8525
  };
8199
- }, [stableOptions, cache]);
8526
+ }, [client, stableOptions]);
8200
8527
  var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
8201
8528
  return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
8202
8529
  var lastTimeout = 0;
8203
- var subscription = cache.watchFragment(stableOptions).subscribe({
8530
+ var subscription = client.watchFragment(stableOptions).subscribe({
8204
8531
  next: function (result) {
8205
8532
  if (equal__default(result, diff.result))
8206
8533
  return;
@@ -8213,7 +8540,7 @@ function _useFragment(options) {
8213
8540
  subscription.unsubscribe();
8214
8541
  clearTimeout(lastTimeout);
8215
8542
  };
8216
- }, [cache, stableOptions, diff]), getSnapshot, getSnapshot);
8543
+ }, [client, stableOptions, diff]), getSnapshot, getSnapshot);
8217
8544
  }
8218
8545
  function diffToResult(diff) {
8219
8546
  var result = {
@@ -8241,7 +8568,7 @@ function wrapQueryRef(internalQueryRef) {
8241
8568
  return ref;
8242
8569
  }
8243
8570
  function assertWrappedQueryRef(queryRef) {
8244
- invariant(!queryRef || QUERY_REFERENCE_SYMBOL in queryRef, 61);
8571
+ invariant(!queryRef || QUERY_REFERENCE_SYMBOL in queryRef, 68);
8245
8572
  }
8246
8573
  function getWrappedPromise(queryRef) {
8247
8574
  var internalQueryRef = unwrapQueryRef(queryRef);
@@ -8612,11 +8939,11 @@ function validateFetchPolicy(fetchPolicy) {
8612
8939
  "no-cache",
8613
8940
  "cache-and-network",
8614
8941
  ];
8615
- invariant(supportedFetchPolicies.includes(fetchPolicy), 58, fetchPolicy);
8942
+ invariant(supportedFetchPolicies.includes(fetchPolicy), 65, fetchPolicy);
8616
8943
  }
8617
8944
  function validatePartialDataReturn(fetchPolicy, returnPartialData) {
8618
8945
  if (fetchPolicy === "no-cache" && returnPartialData) {
8619
- globalThis.__DEV__ !== false && invariant.warn(59);
8946
+ globalThis.__DEV__ !== false && invariant.warn(66);
8620
8947
  }
8621
8948
  }
8622
8949
  function toApolloError(result) {
@@ -8736,7 +9063,7 @@ function useLoadableQuery(query, options) {
8736
9063
  for (var _i = 0; _i < arguments.length; _i++) {
8737
9064
  args[_i] = arguments[_i];
8738
9065
  }
8739
- invariant(!calledDuringRender(), 51);
9066
+ invariant(!calledDuringRender(), 58);
8740
9067
  var variables = args[0];
8741
9068
  var cacheKey = tslib.__spreadArray([
8742
9069
  query,
@@ -8755,7 +9082,7 @@ function useLoadableQuery(query, options) {
8755
9082
  client,
8756
9083
  ]);
8757
9084
  var subscribeToMore = React__namespace.useCallback(function (options) {
8758
- invariant(internalQueryRef, 52);
9085
+ invariant(internalQueryRef, 59);
8759
9086
  return internalQueryRef.observable.subscribeToMore(options);
8760
9087
  }, [internalQueryRef]);
8761
9088
  var reset = React__namespace.useCallback(function () {