@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
@@ -22,7 +22,7 @@ function shouldInclude(_a, variables) {
22
22
  if (ifArgument.value.kind === "Variable") {
23
23
  evaledValue =
24
24
  variables && variables[ifArgument.value.name.value];
25
- globals.invariant(evaledValue !== void 0, 70, directive.name.value);
25
+ globals.invariant(evaledValue !== void 0, 77, directive.name.value);
26
26
  }
27
27
  else {
28
28
  evaledValue = ifArgument.value.value;
@@ -72,17 +72,50 @@ function getInclusionDirectives(directives) {
72
72
  return;
73
73
  var directiveArguments = directive.arguments;
74
74
  var directiveName = directive.name.value;
75
- globals.invariant(directiveArguments && directiveArguments.length === 1, 71, directiveName);
75
+ globals.invariant(directiveArguments && directiveArguments.length === 1, 78, directiveName);
76
76
  var ifArgument = directiveArguments[0];
77
- globals.invariant(ifArgument.name && ifArgument.name.value === "if", 72, directiveName);
77
+ globals.invariant(ifArgument.name && ifArgument.name.value === "if", 79, directiveName);
78
78
  var ifValue = ifArgument.value;
79
79
  globals.invariant(ifValue &&
80
- (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 73, directiveName);
80
+ (ifValue.kind === "Variable" || ifValue.kind === "BooleanValue"), 80, directiveName);
81
81
  result.push({ directive: directive, ifArgument: ifArgument });
82
82
  });
83
83
  }
84
84
  return result;
85
85
  }
86
+ function getFragmentMaskMode(fragment) {
87
+ var _a, _b;
88
+ var directive = (_a = fragment.directives) === null || _a === void 0 ? void 0 : _a.find(function (_a) {
89
+ var name = _a.name;
90
+ return name.value === "unmask";
91
+ });
92
+ if (!directive) {
93
+ return "mask";
94
+ }
95
+ var modeArg = (_b = directive.arguments) === null || _b === void 0 ? void 0 : _b.find(function (_a) {
96
+ var name = _a.name;
97
+ return name.value === "mode";
98
+ });
99
+ if (globalThis.__DEV__ !== false) {
100
+ if (modeArg) {
101
+ if (modeArg.value.kind === graphql.Kind.VARIABLE) {
102
+ globalThis.__DEV__ !== false && globals.invariant.warn(81);
103
+ }
104
+ else if (modeArg.value.kind !== graphql.Kind.STRING) {
105
+ globalThis.__DEV__ !== false && globals.invariant.warn(82);
106
+ }
107
+ else if (modeArg.value.value !== "migrate") {
108
+ globalThis.__DEV__ !== false && globals.invariant.warn(83, modeArg.value.value);
109
+ }
110
+ }
111
+ }
112
+ if (modeArg &&
113
+ "value" in modeArg.value &&
114
+ modeArg.value.value === "migrate") {
115
+ return "migrate";
116
+ }
117
+ return "unmask";
118
+ }
86
119
 
87
120
  var isReactNative = globals.maybe(function () { return navigator.product; }) == "ReactNative";
88
121
  var canUseWeakMap = typeof WeakMap === "function" &&
@@ -111,7 +144,7 @@ function getFragmentQueryDocument(document, fragmentName) {
111
144
  document.definitions.forEach(function (definition) {
112
145
  if (definition.kind === "OperationDefinition") {
113
146
  throw globals.newInvariantError(
114
- 74,
147
+ 84,
115
148
  definition.operation,
116
149
  definition.name ? " named '".concat(definition.name.value, "'") : ""
117
150
  );
@@ -121,7 +154,7 @@ function getFragmentQueryDocument(document, fragmentName) {
121
154
  }
122
155
  });
123
156
  if (typeof actualFragmentName === "undefined") {
124
- globals.invariant(fragments.length === 1, 75, fragments.length);
157
+ globals.invariant(fragments.length === 1, 85, fragments.length);
125
158
  actualFragmentName = fragments[0].name.value;
126
159
  }
127
160
  var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
@@ -162,7 +195,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
162
195
  return fragmentMap(fragmentName);
163
196
  }
164
197
  var fragment = fragmentMap && fragmentMap[fragmentName];
165
- globals.invariant(fragment, 76, fragmentName);
198
+ globals.invariant(fragment, 86, fragmentName);
166
199
  return fragment || null;
167
200
  }
168
201
  default:
@@ -321,7 +354,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
321
354
  argObj[name.value] = null;
322
355
  }
323
356
  else {
324
- throw globals.newInvariantError(85, name.value, value.kind);
357
+ throw globals.newInvariantError(95, name.value, value.kind);
325
358
  }
326
359
  }
327
360
  function storeKeyNameFromField(field, variables) {
@@ -455,16 +488,16 @@ function isInlineFragment(selection) {
455
488
  }
456
489
 
457
490
  function checkDocument(doc) {
458
- globals.invariant(doc && doc.kind === "Document", 77);
491
+ globals.invariant(doc && doc.kind === "Document", 87);
459
492
  var operations = doc.definitions
460
493
  .filter(function (d) { return d.kind !== "FragmentDefinition"; })
461
494
  .map(function (definition) {
462
495
  if (definition.kind !== "OperationDefinition") {
463
- throw globals.newInvariantError(78, definition.kind);
496
+ throw globals.newInvariantError(88, definition.kind);
464
497
  }
465
498
  return definition;
466
499
  });
467
- globals.invariant(operations.length <= 1, 79, operations.length);
500
+ globals.invariant(operations.length <= 1, 89, operations.length);
468
501
  return doc;
469
502
  }
470
503
  function getOperationDefinition(doc) {
@@ -487,14 +520,14 @@ function getFragmentDefinitions(doc) {
487
520
  }
488
521
  function getQueryDefinition(doc) {
489
522
  var queryDef = getOperationDefinition(doc);
490
- globals.invariant(queryDef && queryDef.operation === "query", 80);
523
+ globals.invariant(queryDef && queryDef.operation === "query", 90);
491
524
  return queryDef;
492
525
  }
493
526
  function getFragmentDefinition(doc) {
494
- globals.invariant(doc.kind === "Document", 81);
495
- globals.invariant(doc.definitions.length <= 1, 82);
527
+ globals.invariant(doc.kind === "Document", 91);
528
+ globals.invariant(doc.definitions.length <= 1, 92);
496
529
  var fragmentDef = doc.definitions[0];
497
- globals.invariant(fragmentDef.kind === "FragmentDefinition", 83);
530
+ globals.invariant(fragmentDef.kind === "FragmentDefinition", 93);
498
531
  return fragmentDef;
499
532
  }
500
533
  function getMainDefinition(queryDoc) {
@@ -517,7 +550,7 @@ function getMainDefinition(queryDoc) {
517
550
  if (fragmentDefinition) {
518
551
  return fragmentDefinition;
519
552
  }
520
- throw globals.newInvariantError(84);
553
+ throw globals.newInvariantError(94);
521
554
  }
522
555
  function getDefaultValues(definition) {
523
556
  var defaultValues = Object.create(null);
@@ -568,7 +601,7 @@ var DocumentTransform = (function () {
568
601
  makeCacheKey: function (document) {
569
602
  var cacheKeys = _this.getCacheKey(document);
570
603
  if (cacheKeys) {
571
- globals.invariant(Array.isArray(cacheKeys), 69);
604
+ globals.invariant(Array.isArray(cacheKeys), 76);
572
605
  return stableCacheKeys_1.lookupArray(cacheKeys);
573
606
  }
574
607
  },
@@ -698,7 +731,7 @@ function removeDirectivesFromDocument(directives, doc) {
698
731
  return getInUseByFragmentName(ancestor.name.value);
699
732
  }
700
733
  }
701
- globalThis.__DEV__ !== false && globals.invariant.error(86);
734
+ globalThis.__DEV__ !== false && globals.invariant.error(96);
702
735
  return null;
703
736
  };
704
737
  var operationCount = 0;
@@ -888,7 +921,7 @@ var connectionRemoveConfig = {
888
921
  if (willRemove) {
889
922
  if (!directive.arguments ||
890
923
  !directive.arguments.some(function (arg) { return arg.name.value === "key"; })) {
891
- globalThis.__DEV__ !== false && globals.invariant.warn(87);
924
+ globalThis.__DEV__ !== false && globals.invariant.warn(97);
892
925
  }
893
926
  }
894
927
  return willRemove;
@@ -984,6 +1017,19 @@ function removeClientSetsFromDocument(document) {
984
1017
  ], document);
985
1018
  return modifiedDoc;
986
1019
  }
1020
+ function addNonReactiveToNamedFragments(document) {
1021
+ checkDocument(document);
1022
+ return graphql.visit(document, {
1023
+ FragmentSpread: function (node) {
1024
+ return tslib.__assign(tslib.__assign({}, node), { directives: tslib.__spreadArray(tslib.__spreadArray([], (node.directives || []), true), [
1025
+ {
1026
+ kind: graphql.Kind.DIRECTIVE,
1027
+ name: { kind: graphql.Kind.NAME, value: "nonreactive" },
1028
+ },
1029
+ ], false) });
1030
+ },
1031
+ });
1032
+ }
987
1033
 
988
1034
  function isOperation(document, operation) {
989
1035
  var _a;
@@ -1266,6 +1312,11 @@ function wrapPromiseWithState(promise) {
1266
1312
  return promise;
1267
1313
  }
1268
1314
 
1315
+ function preventUnhandledRejection(promise) {
1316
+ promise.catch(function () { });
1317
+ return promise;
1318
+ }
1319
+
1269
1320
  var toString = Object.prototype.toString;
1270
1321
  function cloneDeep(value) {
1271
1322
  return cloneDeepHelper(value);
@@ -1654,6 +1705,7 @@ exports.AutoCleanedWeakCache = AutoCleanedWeakCache;
1654
1705
  exports.Concast = Concast;
1655
1706
  exports.DeepMerger = DeepMerger;
1656
1707
  exports.DocumentTransform = DocumentTransform;
1708
+ exports.addNonReactiveToNamedFragments = addNonReactiveToNamedFragments;
1657
1709
  exports.addTypenameToDocument = addTypenameToDocument;
1658
1710
  exports.argumentsObjectFromField = argumentsObjectFromField;
1659
1711
  exports.asyncMap = asyncMap;
@@ -1679,6 +1731,7 @@ exports.getDirectiveNames = getDirectiveNames;
1679
1731
  exports.getFragmentDefinition = getFragmentDefinition;
1680
1732
  exports.getFragmentDefinitions = getFragmentDefinitions;
1681
1733
  exports.getFragmentFromSelection = getFragmentFromSelection;
1734
+ exports.getFragmentMaskMode = getFragmentMaskMode;
1682
1735
  exports.getFragmentQueryDocument = getFragmentQueryDocument;
1683
1736
  exports.getGraphQLErrorsFromResult = getGraphQLErrorsFromResult;
1684
1737
  exports.getInclusionDirectives = getInclusionDirectives;
@@ -1719,6 +1772,7 @@ exports.mergeIncrementalData = mergeIncrementalData;
1719
1772
  exports.mergeOptions = mergeOptions;
1720
1773
  exports.offsetLimitPagination = offsetLimitPagination;
1721
1774
  exports.omitDeep = omitDeep;
1775
+ exports.preventUnhandledRejection = preventUnhandledRejection;
1722
1776
  exports.print = print;
1723
1777
  exports.relayStylePagination = relayStylePagination;
1724
1778
  exports.removeArgumentsFromDocument = removeArgumentsFromDocument;
package/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export var version = "3.11.7";
1
+ export var version = "3.12.0-alpha.0";
2
2
  //# sourceMappingURL=version.js.map