@apollo/client 3.12.0-rc.2 → 3.12.0-rc.4

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 (86) hide show
  1. package/.changeset/clean-turkeys-kick.md +5 -0
  2. package/.changeset/happy-months-happen.md +5 -0
  3. package/.changeset/perfect-jobs-flow.md +5 -0
  4. package/.changeset/pre.json +3 -0
  5. package/CHANGELOG.md +14 -0
  6. package/apollo-client.cjs +74 -72
  7. package/apollo-client.cjs.map +1 -1
  8. package/apollo-client.min.cjs +1 -1
  9. package/cache/cache.cjs +4 -166
  10. package/cache/cache.cjs.map +1 -1
  11. package/cache/cache.cjs.native.js +4 -166
  12. package/cache/core/cache.js +1 -1
  13. package/cache/core/cache.js.map +1 -1
  14. package/cache/inmemory/policies.js +1 -1
  15. package/cache/inmemory/policies.js.map +1 -1
  16. package/core/QueryManager.js +1 -1
  17. package/core/QueryManager.js.map +1 -1
  18. package/core/core.cjs +4 -189
  19. package/core/core.cjs.map +1 -1
  20. package/core/core.cjs.native.js +4 -189
  21. package/dev/dev.cjs +37 -37
  22. package/dev/dev.cjs.map +1 -1
  23. package/dev/dev.cjs.native.js +37 -37
  24. package/invariantErrorCodes.js +42 -42
  25. package/link/core/ApolloLink.js +2 -2
  26. package/link/core/core.cjs +2 -2
  27. package/link/core/core.cjs.map +1 -1
  28. package/link/core/core.cjs.native.js +2 -2
  29. package/link/http/checkFetcher.js +1 -1
  30. package/link/http/createHttpLink.js +1 -1
  31. package/link/http/http.cjs +3 -3
  32. package/link/http/http.cjs.map +1 -1
  33. package/link/http/http.cjs.native.js +3 -3
  34. package/link/http/serializeFetchParameter.js +1 -1
  35. package/link/persisted-queries/index.js +2 -2
  36. package/link/persisted-queries/persisted-queries.cjs +2 -2
  37. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  38. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  39. package/link/utils/toPromise.js +1 -1
  40. package/link/utils/utils.cjs +2 -2
  41. package/link/utils/utils.cjs.map +1 -1
  42. package/link/utils/utils.cjs.native.js +2 -2
  43. package/link/utils/validateOperation.js +1 -1
  44. package/masking/__benches__/types.bench.d.ts +2 -0
  45. package/masking/__benches__/types.bench.js +131 -0
  46. package/masking/__benches__/types.bench.js.map +1 -0
  47. package/masking/index.d.ts +3 -0
  48. package/masking/index.js +3 -1
  49. package/masking/index.js.map +1 -1
  50. package/masking/internal/types.d.ts +115 -9
  51. package/masking/internal/types.js.map +1 -1
  52. package/masking/maskDefinition.d.ts +14 -0
  53. package/{core/masking.js → masking/maskDefinition.js} +11 -83
  54. package/masking/maskDefinition.js.map +1 -0
  55. package/masking/maskFragment.d.ts +4 -0
  56. package/masking/maskFragment.js +43 -0
  57. package/masking/maskFragment.js.map +1 -0
  58. package/masking/maskOperation.d.ts +4 -0
  59. package/masking/maskOperation.js +29 -0
  60. package/masking/maskOperation.js.map +1 -0
  61. package/masking/masking.cjs +202 -0
  62. package/masking/masking.cjs.map +1 -1
  63. package/masking/masking.cjs.native.js +202 -0
  64. package/masking/types.d.ts +4 -4
  65. package/masking/types.js.map +1 -1
  66. package/masking/utils.d.ts +11 -0
  67. package/masking/utils.js +17 -0
  68. package/masking/utils.js.map +1 -0
  69. package/package.json +3 -1
  70. package/react/hoc/hoc.cjs.map +1 -1
  71. package/react/hoc/mutation-hoc.js +3 -2
  72. package/react/hoc/mutation-hoc.js.map +1 -1
  73. package/react/internal/internal.cjs +1 -1
  74. package/react/internal/internal.cjs.map +1 -1
  75. package/react/internal/internal.cjs.native.js +1 -1
  76. package/react/types/types.d.ts +5 -1
  77. package/react/types/types.documentation.d.ts +7 -1
  78. package/react/types/types.documentation.js.map +1 -1
  79. package/testing/internal/scenarios/index.d.ts +1 -0
  80. package/testing/internal/scenarios/index.js.map +1 -1
  81. package/utilities/globals/globals.cjs +1 -1
  82. package/utilities/globals/globals.cjs.map +1 -1
  83. package/utilities/globals/globals.cjs.native.js +1 -1
  84. package/version.js +1 -1
  85. package/core/masking.d.ts +0 -10
  86. package/core/masking.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Fix issue when using `Unmasked` with older versions of TypeScript when used with array fields.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Data masking types: handle overlapping nested array types and fragments on interface types.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Add a helper that will skip the TS unmasking alorithm when no fragments are present on type level
@@ -6,10 +6,12 @@
6
6
  },
7
7
  "changesets": [
8
8
  "brown-readers-smash",
9
+ "clean-turkeys-kick",
9
10
  "cold-apes-bow",
10
11
  "early-bobcats-eat",
11
12
  "flat-beans-knock",
12
13
  "gorgeous-zebras-confess",
14
+ "happy-months-happen",
13
15
  "itchy-penguins-worry",
14
16
  "kind-toys-tie",
15
17
  "long-zoos-ring",
@@ -17,6 +19,7 @@
17
19
  "nasty-camels-pay",
18
20
  "nervous-owls-hear",
19
21
  "nice-countries-share",
22
+ "perfect-jobs-flow",
20
23
  "slimy-points-end",
21
24
  "small-bears-confess",
22
25
  "wicked-pans-appear"
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.12.0-rc.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#12154](https://github.com/apollographql/apollo-client/pull/12154) [`d933def`](https://github.com/apollographql/apollo-client/commit/d933def986d476cd64321059299ab15031297f04) Thanks [@phryneas](https://github.com/phryneas)! - Data masking types: handle overlapping nested array types and fragments on interface types.
8
+
9
+ ## 3.12.0-rc.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#12150](https://github.com/apollographql/apollo-client/pull/12150) [`9ed1e1e`](https://github.com/apollographql/apollo-client/commit/9ed1e1ef02b28445614fed4f5c141a289ac32d66) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue when using `Unmasked` with older versions of TypeScript when used with array fields.
14
+
15
+ - [#12152](https://github.com/apollographql/apollo-client/pull/12152) [`78137ec`](https://github.com/apollographql/apollo-client/commit/78137eccba90b80dd29bd8e1423b49ebe51ef8df) Thanks [@phryneas](https://github.com/phryneas)! - Add a helper that will skip the TS unmasking alorithm when no fragments are present on type level
16
+
3
17
  ## 3.12.0-rc.2
4
18
 
5
19
  ### Patch Changes
package/apollo-client.cjs CHANGED
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
31
31
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
32
32
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
33
 
34
- var version = "3.12.0-rc.2";
34
+ var version = "3.12.0-rc.4";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -1615,7 +1615,7 @@ function toPromise(observable) {
1615
1615
  observable.subscribe({
1616
1616
  next: function (data) {
1617
1617
  if (completed) {
1618
- globalThis.__DEV__ !== false && invariant.warn(51);
1618
+ globalThis.__DEV__ !== false && invariant.warn(45);
1619
1619
  }
1620
1620
  else {
1621
1621
  completed = true;
@@ -1658,7 +1658,7 @@ function validateOperation(operation) {
1658
1658
  for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
1659
1659
  var key = _a[_i];
1660
1660
  if (OPERATION_FIELDS.indexOf(key) < 0) {
1661
- throw newInvariantError(52, key);
1661
+ throw newInvariantError(46, key);
1662
1662
  }
1663
1663
  }
1664
1664
  return operation;
@@ -1767,7 +1767,7 @@ var ApolloLink = (function () {
1767
1767
  ApolloLink.concat = function (first, second) {
1768
1768
  var firstLink = toLink(first);
1769
1769
  if (isTerminating(firstLink)) {
1770
- globalThis.__DEV__ !== false && invariant.warn(44, firstLink);
1770
+ globalThis.__DEV__ !== false && invariant.warn(38, firstLink);
1771
1771
  return firstLink;
1772
1772
  }
1773
1773
  var nextLink = toLink(second);
@@ -1793,7 +1793,7 @@ var ApolloLink = (function () {
1793
1793
  return ApolloLink.concat(this, next);
1794
1794
  };
1795
1795
  ApolloLink.prototype.request = function (operation, forward) {
1796
- throw newInvariantError(45);
1796
+ throw newInvariantError(39);
1797
1797
  };
1798
1798
  ApolloLink.prototype.onError = function (error, observer) {
1799
1799
  if (observer && observer.error) {
@@ -2175,7 +2175,7 @@ var serializeFetchParameter = function (p, label) {
2175
2175
  serialized = JSON.stringify(p);
2176
2176
  }
2177
2177
  catch (e) {
2178
- var parseError = newInvariantError(48, label, e.message);
2178
+ var parseError = newInvariantError(42, label, e.message);
2179
2179
  parseError.parseError = e;
2180
2180
  throw parseError;
2181
2181
  }
@@ -2261,7 +2261,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
2261
2261
 
2262
2262
  var checkFetcher = function (fetcher) {
2263
2263
  if (!fetcher && typeof fetch === "undefined") {
2264
- throw newInvariantError(46);
2264
+ throw newInvariantError(40);
2265
2265
  }
2266
2266
  };
2267
2267
 
@@ -2395,7 +2395,7 @@ var createHttpLink = function (linkOptions) {
2395
2395
  options.headers = options.headers || {};
2396
2396
  var acceptHeader = "multipart/mixed;";
2397
2397
  if (isSubscription && hasDefer) {
2398
- globalThis.__DEV__ !== false && invariant.warn(47);
2398
+ globalThis.__DEV__ !== false && invariant.warn(41);
2399
2399
  }
2400
2400
  if (isSubscription) {
2401
2401
  acceptHeader +=
@@ -2532,59 +2532,14 @@ function directiveIsNonreactive(dir) {
2532
2532
  var MapImpl = canUseWeakMap ? WeakMap : Map;
2533
2533
  var SetImpl = canUseWeakSet ? WeakSet : Set;
2534
2534
  var disableWarningsSlot = new optimism.Slot();
2535
- function maskOperation(data, document, cache) {
2536
- var _a;
2537
- if (!cache.fragmentMatches) {
2538
- if (globalThis.__DEV__ !== false) {
2539
- warnOnImproperCacheImplementation();
2540
- }
2541
- return data;
2542
- }
2543
- var definition = getOperationDefinition(document);
2544
- invariant(definition, 38);
2545
- if (data == null) {
2546
- return data;
2547
- }
2548
- return maskDefinition(data, definition.selectionSet, {
2549
- operationType: definition.operation,
2550
- operationName: (_a = definition.name) === null || _a === void 0 ? void 0 : _a.value,
2551
- fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2552
- cache: cache,
2553
- mutableTargets: new MapImpl(),
2554
- knownChanged: new SetImpl(),
2555
- });
2556
- }
2557
- function maskFragment(data, document, cache, fragmentName) {
2558
- if (!cache.fragmentMatches) {
2559
- if (globalThis.__DEV__ !== false) {
2560
- warnOnImproperCacheImplementation();
2561
- }
2562
- return data;
2563
- }
2564
- var fragments = document.definitions.filter(function (node) {
2565
- return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
2566
- });
2567
- if (typeof fragmentName === "undefined") {
2568
- invariant(fragments.length === 1, 39, fragments.length);
2569
- fragmentName = fragments[0].name.value;
2570
- }
2571
- var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
2572
- invariant(!!fragment, 40, fragmentName);
2573
- if (data == null) {
2574
- return data;
2575
- }
2576
- if (equal.equal(data, {})) {
2577
- return data;
2535
+ var issuedWarning = false;
2536
+ function warnOnImproperCacheImplementation() {
2537
+ if (!issuedWarning) {
2538
+ issuedWarning = true;
2539
+ globalThis.__DEV__ !== false && invariant.warn(52);
2578
2540
  }
2579
- return maskDefinition(data, fragment.selectionSet, {
2580
- operationType: "fragment",
2581
- operationName: fragment.name.value,
2582
- fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2583
- cache: cache,
2584
- mutableTargets: new MapImpl(),
2585
- knownChanged: new SetImpl(),
2586
- });
2587
2541
  }
2542
+
2588
2543
  function maskDefinition(data, selectionSet, context) {
2589
2544
  return disableWarningsSlot.withValue(true, function () {
2590
2545
  var masked = maskSelectionSet(data, selectionSet, context, false);
@@ -2605,23 +2560,22 @@ function getMutableTarget(data, mutableTargets) {
2605
2560
  function maskSelectionSet(data, selectionSet, context, migration, path) {
2606
2561
  var _a;
2607
2562
  var knownChanged = context.knownChanged;
2563
+ var memo = getMutableTarget(data, context.mutableTargets);
2608
2564
  if (Array.isArray(data)) {
2609
- var target = getMutableTarget(data, context.mutableTargets);
2610
2565
  for (var _i = 0, _b = Array.from(data.entries()); _i < _b.length; _i++) {
2611
2566
  var _c = _b[_i], index = _c[0], item = _c[1];
2612
2567
  if (item === null) {
2613
- target[index] = null;
2568
+ memo[index] = null;
2614
2569
  continue;
2615
2570
  }
2616
2571
  var masked = maskSelectionSet(item, selectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0);
2617
2572
  if (knownChanged.has(masked)) {
2618
- knownChanged.add(target);
2573
+ knownChanged.add(memo);
2619
2574
  }
2620
- target[index] = masked;
2575
+ memo[index] = masked;
2621
2576
  }
2622
- return knownChanged.has(target) ? target : data;
2577
+ return knownChanged.has(memo) ? memo : data;
2623
2578
  }
2624
- var memo = getMutableTarget(data, context.mutableTargets);
2625
2579
  for (var _d = 0, _e = selectionSet.selections; _d < _e.length; _d++) {
2626
2580
  var selection = _e[_d];
2627
2581
  var value = void 0;
@@ -2666,7 +2620,7 @@ function maskSelectionSet(data, selectionSet, context, migration, path) {
2666
2620
  var fragment = context.fragmentMap[fragmentName] ||
2667
2621
  (context.fragmentMap[fragmentName] =
2668
2622
  context.cache.lookupFragment(fragmentName));
2669
- invariant(fragment, 41, fragmentName);
2623
+ invariant(fragment, 47, fragmentName);
2670
2624
  var mode = getFragmentMaskMode(selection);
2671
2625
  if (mode !== "mask") {
2672
2626
  value = maskSelectionSet(data, fragment.selectionSet, context, mode === "migrate", path);
@@ -2689,7 +2643,7 @@ function getAccessorWarningDescriptor(fieldName, value, path, operationName, ope
2689
2643
  if (disableWarningsSlot.getValue()) {
2690
2644
  return value;
2691
2645
  }
2692
- globalThis.__DEV__ !== false && invariant.warn(42, operationName ?
2646
+ globalThis.__DEV__ !== false && invariant.warn(48, operationName ?
2693
2647
  "".concat(operationType, " '").concat(operationName, "'")
2694
2648
  : "anonymous ".concat(operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
2695
2649
  getValue = function () { return value; };
@@ -2706,12 +2660,60 @@ function getAccessorWarningDescriptor(fieldName, value, path, operationName, ope
2706
2660
  configurable: true,
2707
2661
  };
2708
2662
  }
2709
- var issuedWarning = false;
2710
- function warnOnImproperCacheImplementation() {
2711
- if (!issuedWarning) {
2712
- issuedWarning = true;
2713
- globalThis.__DEV__ !== false && invariant.warn(43);
2663
+
2664
+ function maskFragment(data, document, cache, fragmentName) {
2665
+ if (!cache.fragmentMatches) {
2666
+ if (globalThis.__DEV__ !== false) {
2667
+ warnOnImproperCacheImplementation();
2668
+ }
2669
+ return data;
2714
2670
  }
2671
+ var fragments = document.definitions.filter(function (node) {
2672
+ return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
2673
+ });
2674
+ if (typeof fragmentName === "undefined") {
2675
+ invariant(fragments.length === 1, 49, fragments.length);
2676
+ fragmentName = fragments[0].name.value;
2677
+ }
2678
+ var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
2679
+ invariant(!!fragment, 50, fragmentName);
2680
+ if (data == null) {
2681
+ return data;
2682
+ }
2683
+ if (equal__default(data, {})) {
2684
+ return data;
2685
+ }
2686
+ return maskDefinition(data, fragment.selectionSet, {
2687
+ operationType: "fragment",
2688
+ operationName: fragment.name.value,
2689
+ fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2690
+ cache: cache,
2691
+ mutableTargets: new MapImpl(),
2692
+ knownChanged: new SetImpl(),
2693
+ });
2694
+ }
2695
+
2696
+ function maskOperation(data, document, cache) {
2697
+ var _a;
2698
+ if (!cache.fragmentMatches) {
2699
+ if (globalThis.__DEV__ !== false) {
2700
+ warnOnImproperCacheImplementation();
2701
+ }
2702
+ return data;
2703
+ }
2704
+ var definition = getOperationDefinition(document);
2705
+ invariant(definition, 51);
2706
+ if (data == null) {
2707
+ return data;
2708
+ }
2709
+ return maskDefinition(data, definition.selectionSet, {
2710
+ operationType: definition.operation,
2711
+ operationName: (_a = definition.name) === null || _a === void 0 ? void 0 : _a.value,
2712
+ fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2713
+ cache: cache,
2714
+ mutableTargets: new MapImpl(),
2715
+ knownChanged: new SetImpl(),
2716
+ });
2715
2717
  }
2716
2718
 
2717
2719
  var ApolloCache = (function () {