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

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 (41) hide show
  1. package/.changeset/brown-readers-smash.md +5 -0
  2. package/.changeset/gorgeous-zebras-confess.md +5 -0
  3. package/.changeset/itchy-penguins-worry.md +5 -0
  4. package/.changeset/long-zoos-ring.md +5 -0
  5. package/.changeset/mean-bottles-travel.md +5 -0
  6. package/.changeset/nice-countries-share.md +5 -0
  7. package/.changeset/pre.json +10 -1
  8. package/.changeset/slimy-points-end.md +5 -0
  9. package/.changeset/small-bears-confess.md +5 -0
  10. package/.changeset/wicked-pans-appear.md +5 -0
  11. package/CHANGELOG.md +28 -0
  12. package/apollo-client.cjs +128 -138
  13. package/apollo-client.cjs.map +1 -1
  14. package/apollo-client.min.cjs +1 -1
  15. package/cache/cache.cjs +98 -119
  16. package/cache/cache.cjs.map +1 -1
  17. package/cache/cache.cjs.native.js +98 -119
  18. package/core/core.cjs +103 -127
  19. package/core/core.cjs.map +1 -1
  20. package/core/core.cjs.native.js +103 -127
  21. package/core/masking.js +112 -136
  22. package/core/masking.js.map +1 -1
  23. package/dev/dev.cjs +1 -1
  24. package/dev/dev.cjs.map +1 -1
  25. package/dev/dev.cjs.native.js +1 -1
  26. package/masking/internal/types.d.ts +2 -2
  27. package/masking/internal/types.js.map +1 -1
  28. package/package.json +1 -1
  29. package/react/hooks/hooks.cjs +25 -11
  30. package/react/hooks/hooks.cjs.map +1 -1
  31. package/react/hooks/hooks.cjs.native.js +25 -11
  32. package/react/hooks/useFragment.d.ts +1 -1
  33. package/react/hooks/useFragment.js +33 -19
  34. package/react/hooks/useFragment.js.map +1 -1
  35. package/react/internal/internal.cjs +1 -1
  36. package/react/internal/internal.cjs.map +1 -1
  37. package/react/internal/internal.cjs.native.js +1 -1
  38. package/utilities/globals/globals.cjs +1 -1
  39. package/utilities/globals/globals.cjs.map +1 -1
  40. package/utilities/globals/globals.cjs.native.js +1 -1
  41. package/version.js +1 -1
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Maintain the existing document if its unchanged by the codemod and move to more naive whitespace formatting
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Fix issue where data went missing when an unmasked fragment in migrate mode selected fields that the parent did not.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Fix issue where masked data would sometimes get returned when the field was part of a child fragment from a fragment unmasked by the parent query.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": minor
3
+ ---
4
+
5
+ Allow `null` as a valid `from` value in `useFragment`.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Fix issue where the warning emitted by `@unmask(mode: "migrate")` would trigger unnecessarily when the fragment was used alongside a masked fragment inside an inline fragment.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Fix error thrown when applying unmask migrate mode warnings on interface types with selection sets that contain inline fragment conditions.
@@ -5,11 +5,20 @@
5
5
  "@apollo/client": "3.11.5"
6
6
  },
7
7
  "changesets": [
8
+ "brown-readers-smash",
8
9
  "cold-apes-bow",
9
10
  "early-bobcats-eat",
10
11
  "flat-beans-knock",
12
+ "gorgeous-zebras-confess",
13
+ "itchy-penguins-worry",
11
14
  "kind-toys-tie",
15
+ "long-zoos-ring",
16
+ "mean-bottles-travel",
12
17
  "nasty-camels-pay",
13
- "nervous-owls-hear"
18
+ "nervous-owls-hear",
19
+ "nice-countries-share",
20
+ "slimy-points-end",
21
+ "small-bears-confess",
22
+ "wicked-pans-appear"
14
23
  ]
15
24
  }
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Ensure documents unchanged by the codemod are left untouched.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Ensure `null` is retained in nullable types when unmasking a type with the `Unmasked` helper type.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@apollo/client": patch
3
+ ---
4
+
5
+ Fix issue that threw errors when masking partial data with `@unmask(mode: "migrate")`.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # @apollo/client
2
2
 
3
+ ## 3.12.0-rc.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#12139](https://github.com/apollographql/apollo-client/pull/12139) [`5a53e15`](https://github.com/apollographql/apollo-client/commit/5a53e15e713e5eb2ebc9216615ea1a845fad2685) Thanks [@phryneas](https://github.com/phryneas)! - Fix issue where masked data would sometimes get returned when the field was part of a child fragment from a fragment unmasked by the parent query.
8
+
9
+ - [#12139](https://github.com/apollographql/apollo-client/pull/12139) [`5a53e15`](https://github.com/apollographql/apollo-client/commit/5a53e15e713e5eb2ebc9216615ea1a845fad2685) Thanks [@phryneas](https://github.com/phryneas)! - Fix issue where the warning emitted by `@unmask(mode: "migrate")` would trigger unnecessarily when the fragment was used alongside a masked fragment inside an inline fragment.
10
+
11
+ - [#12139](https://github.com/apollographql/apollo-client/pull/12139) [`5a53e15`](https://github.com/apollographql/apollo-client/commit/5a53e15e713e5eb2ebc9216615ea1a845fad2685) Thanks [@phryneas](https://github.com/phryneas)! - Fix issue that threw errors when masking partial data with `@unmask(mode: "migrate")`.
12
+
13
+ ## 3.12.0-rc.1
14
+
15
+ ### Minor Changes
16
+
17
+ - [#12131](https://github.com/apollographql/apollo-client/pull/12131) [`21c3f08`](https://github.com/apollographql/apollo-client/commit/21c3f083013445707b7b50ae6390318bc568d0f5) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Allow `null` as a valid `from` value in `useFragment`.
18
+
19
+ ### Patch Changes
20
+
21
+ - [#12126](https://github.com/apollographql/apollo-client/pull/12126) [`d10d702`](https://github.com/apollographql/apollo-client/commit/d10d702ee9bd4d1d1dee2551821140f2c49d5c0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Maintain the existing document if its unchanged by the codemod and move to more naive whitespace formatting
22
+
23
+ - [#12134](https://github.com/apollographql/apollo-client/pull/12134) [`cfaf4ef`](https://github.com/apollographql/apollo-client/commit/cfaf4efc6dea56ae46a5b5199d8ed9414b0f17d8) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix issue where data went missing when an unmasked fragment in migrate mode selected fields that the parent did not.
24
+
25
+ - [#12130](https://github.com/apollographql/apollo-client/pull/12130) [`1e7d009`](https://github.com/apollographql/apollo-client/commit/1e7d009e4a52949dab0065f3219dfe148837531e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix error thrown when applying unmask migrate mode warnings on interface types with selection sets that contain inline fragment conditions.
26
+
27
+ - [#12126](https://github.com/apollographql/apollo-client/pull/12126) [`d10d702`](https://github.com/apollographql/apollo-client/commit/d10d702ee9bd4d1d1dee2551821140f2c49d5c0c) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure documents unchanged by the codemod are left untouched.
28
+
29
+ - [#12133](https://github.com/apollographql/apollo-client/pull/12133) [`a6ece37`](https://github.com/apollographql/apollo-client/commit/a6ece375119ce12c19749471c55b0059843a7217) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure `null` is retained in nullable types when unmasking a type with the `Unmasked` helper type.
30
+
3
31
  ## 3.12.0-rc.0
4
32
 
5
33
  ### 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.0";
34
+ var version = "3.12.0-rc.2";
35
35
 
36
36
  function maybe(thunk) {
37
37
  try {
@@ -2529,6 +2529,8 @@ function directiveIsNonreactive(dir) {
2529
2529
  return dir.name.value === "nonreactive";
2530
2530
  }
2531
2531
 
2532
+ var MapImpl = canUseWeakMap ? WeakMap : Map;
2533
+ var SetImpl = canUseWeakSet ? WeakSet : Set;
2532
2534
  var disableWarningsSlot = new optimism.Slot();
2533
2535
  function maskOperation(data, document, cache) {
2534
2536
  var _a;
@@ -2543,17 +2545,14 @@ function maskOperation(data, document, cache) {
2543
2545
  if (data == null) {
2544
2546
  return data;
2545
2547
  }
2546
- var context = {
2548
+ return maskDefinition(data, definition.selectionSet, {
2547
2549
  operationType: definition.operation,
2548
2550
  operationName: (_a = definition.name) === null || _a === void 0 ? void 0 : _a.value,
2549
2551
  fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2550
2552
  cache: cache,
2551
- };
2552
- var _b = maskSelectionSet(data, definition.selectionSet, context), masked = _b[0], changed = _b[1];
2553
- if (Object.isFrozen(data)) {
2554
- disableWarningsSlot.withValue(true, maybeDeepFreeze, [masked]);
2555
- }
2556
- return changed ? masked : data;
2553
+ mutableTargets: new MapImpl(),
2554
+ knownChanged: new SetImpl(),
2555
+ });
2557
2556
  }
2558
2557
  function maskFragment(data, document, cache, fragmentName) {
2559
2558
  if (!cache.fragmentMatches) {
@@ -2577,158 +2576,135 @@ function maskFragment(data, document, cache, fragmentName) {
2577
2576
  if (equal.equal(data, {})) {
2578
2577
  return data;
2579
2578
  }
2580
- var context = {
2579
+ return maskDefinition(data, fragment.selectionSet, {
2581
2580
  operationType: "fragment",
2582
2581
  operationName: fragment.name.value,
2583
2582
  fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
2584
2583
  cache: cache,
2585
- };
2586
- var _a = maskSelectionSet(data, fragment.selectionSet, context), masked = _a[0], changed = _a[1];
2587
- if (Object.isFrozen(data)) {
2588
- disableWarningsSlot.withValue(true, maybeDeepFreeze, [masked]);
2584
+ mutableTargets: new MapImpl(),
2585
+ knownChanged: new SetImpl(),
2586
+ });
2587
+ }
2588
+ function maskDefinition(data, selectionSet, context) {
2589
+ return disableWarningsSlot.withValue(true, function () {
2590
+ var masked = maskSelectionSet(data, selectionSet, context, false);
2591
+ if (Object.isFrozen(data)) {
2592
+ maybeDeepFreeze(masked);
2593
+ }
2594
+ return masked;
2595
+ });
2596
+ }
2597
+ function getMutableTarget(data, mutableTargets) {
2598
+ if (mutableTargets.has(data)) {
2599
+ return mutableTargets.get(data);
2589
2600
  }
2590
- return changed ? masked : data;
2601
+ var mutableTarget = Array.isArray(data) ? [] : Object.create(null);
2602
+ mutableTargets.set(data, mutableTarget);
2603
+ return mutableTarget;
2591
2604
  }
2592
- function maskSelectionSet(data, selectionSet, context, path) {
2605
+ function maskSelectionSet(data, selectionSet, context, migration, path) {
2606
+ var _a;
2607
+ var knownChanged = context.knownChanged;
2593
2608
  if (Array.isArray(data)) {
2594
- var changed_1 = false;
2595
- var masked = data.map(function (item, index) {
2609
+ var target = getMutableTarget(data, context.mutableTargets);
2610
+ for (var _i = 0, _b = Array.from(data.entries()); _i < _b.length; _i++) {
2611
+ var _c = _b[_i], index = _c[0], item = _c[1];
2596
2612
  if (item === null) {
2597
- return null;
2613
+ target[index] = null;
2614
+ continue;
2598
2615
  }
2599
- var _a = maskSelectionSet(item, selectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0), masked = _a[0], itemChanged = _a[1];
2600
- changed_1 || (changed_1 = itemChanged);
2601
- return itemChanged ? masked : item;
2602
- });
2603
- return [changed_1 ? masked : data, changed_1];
2604
- }
2605
- var result = selectionSet.selections.reduce(function (_a, selection) {
2606
- var memo = _a[0], changed = _a[1];
2607
- switch (selection.kind) {
2608
- case graphql.Kind.FIELD: {
2609
- var keyName = resultKeyNameFromField(selection);
2610
- var childSelectionSet = selection.selectionSet;
2611
- memo[keyName] = data[keyName];
2612
- if (memo[keyName] === void 0) {
2613
- delete memo[keyName];
2614
- }
2615
- if (keyName in memo && childSelectionSet && data[keyName] !== null) {
2616
- var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
2617
- if (childChanged ||
2618
- Object.keys(masked).length !== Object.keys(data[keyName]).length) {
2619
- memo[keyName] = masked;
2620
- changed = true;
2621
- }
2622
- }
2623
- return [memo, changed];
2624
- }
2625
- case graphql.Kind.INLINE_FRAGMENT: {
2626
- if (selection.typeCondition &&
2627
- !context.cache.fragmentMatches(selection, data.__typename)) {
2628
- return [memo, changed];
2629
- }
2630
- var _c = maskSelectionSet(data, selection.selectionSet, context, path), fragmentData = _c[0], childChanged = _c[1];
2631
- return [
2632
- tslib.__assign(tslib.__assign({}, memo), fragmentData),
2633
- changed || childChanged,
2634
- ];
2635
- }
2636
- case graphql.Kind.FRAGMENT_SPREAD: {
2637
- var fragmentName = selection.name.value;
2638
- var fragment = context.fragmentMap[fragmentName] ||
2639
- (context.fragmentMap[fragmentName] =
2640
- context.cache.lookupFragment(fragmentName));
2641
- invariant(fragment, 41, fragmentName);
2642
- var mode = getFragmentMaskMode(selection);
2643
- if (mode === "mask") {
2644
- return [memo, true];
2645
- }
2646
- if (globalThis.__DEV__ !== false) {
2647
- if (mode === "migrate") {
2648
- return [
2649
- addFieldAccessorWarnings(memo, data, fragment.selectionSet, path || "", context),
2650
- true,
2651
- ];
2652
- }
2653
- }
2654
- var _d = maskSelectionSet(data, fragment.selectionSet, context, path), fragmentData = _d[0], changed_2 = _d[1];
2655
- return [tslib.__assign(tslib.__assign({}, memo), fragmentData), changed_2];
2616
+ var masked = maskSelectionSet(item, selectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0);
2617
+ if (knownChanged.has(masked)) {
2618
+ knownChanged.add(target);
2656
2619
  }
2620
+ target[index] = masked;
2657
2621
  }
2658
- }, [Object.create(null), false]);
2659
- if (data && "__typename" in data && !("__typename" in result[0])) {
2660
- result[0].__typename = data.__typename;
2661
- }
2662
- return result;
2663
- }
2664
- function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
2665
- if (Array.isArray(data)) {
2666
- return data.map(function (item, index) {
2667
- return addFieldAccessorWarnings(memo[index] || Object.create(null), item, selectionSetNode, "".concat(path, "[").concat(index, "]"), context);
2668
- });
2622
+ return knownChanged.has(target) ? target : data;
2669
2623
  }
2670
- return selectionSetNode.selections.reduce(function (memo, selection) {
2671
- switch (selection.kind) {
2672
- case graphql.Kind.FIELD: {
2673
- var keyName = resultKeyNameFromField(selection);
2674
- var childSelectionSet = selection.selectionSet;
2675
- if (keyName in memo) {
2676
- return memo;
2677
- }
2678
- var value = data[keyName];
2679
- if (childSelectionSet) {
2680
- value = addFieldAccessorWarnings(memo[keyName] || Object.create(null), data[keyName], childSelectionSet, "".concat(path, ".").concat(keyName), context);
2681
- }
2682
- if (globalThis.__DEV__ !== false) {
2683
- addAccessorWarning(memo, value, keyName, path, context);
2684
- }
2685
- if (!(globalThis.__DEV__ !== false)) {
2686
- memo[keyName] = data[keyName];
2624
+ var memo = getMutableTarget(data, context.mutableTargets);
2625
+ for (var _d = 0, _e = selectionSet.selections; _d < _e.length; _d++) {
2626
+ var selection = _e[_d];
2627
+ var value = void 0;
2628
+ if (migration) {
2629
+ knownChanged.add(memo);
2630
+ }
2631
+ if (selection.kind === graphql.Kind.FIELD) {
2632
+ var keyName = resultKeyNameFromField(selection);
2633
+ var childSelectionSet = selection.selectionSet;
2634
+ value = memo[keyName] || data[keyName];
2635
+ if (value === void 0) {
2636
+ continue;
2637
+ }
2638
+ if (childSelectionSet && value !== null) {
2639
+ var masked = maskSelectionSet(data[keyName], childSelectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0);
2640
+ if (knownChanged.has(masked)) {
2641
+ value = masked;
2687
2642
  }
2688
- return memo;
2689
2643
  }
2690
- case graphql.Kind.INLINE_FRAGMENT: {
2691
- return addFieldAccessorWarnings(memo, data, selection.selectionSet, path, context);
2644
+ if (!(globalThis.__DEV__ !== false)) {
2645
+ memo[keyName] = value;
2692
2646
  }
2693
- case graphql.Kind.FRAGMENT_SPREAD: {
2694
- var fragment = context.fragmentMap[selection.name.value];
2695
- var mode = getFragmentMaskMode(selection);
2696
- if (mode === "mask") {
2697
- return memo;
2647
+ if (globalThis.__DEV__ !== false) {
2648
+ if (migration &&
2649
+ keyName !== "__typename" &&
2650
+ !((_a = Object.getOwnPropertyDescriptor(memo, keyName)) === null || _a === void 0 ? void 0 : _a.value)) {
2651
+ Object.defineProperty(memo, keyName, getAccessorWarningDescriptor(keyName, value, path || "", context.operationName, context.operationType));
2698
2652
  }
2699
- if (mode === "unmask") {
2700
- var fragmentData = maskSelectionSet(data, fragment.selectionSet, context, path)[0];
2701
- return Object.assign(memo, fragmentData);
2653
+ else {
2654
+ delete memo[keyName];
2655
+ memo[keyName] = value;
2702
2656
  }
2703
- return addFieldAccessorWarnings(memo, data, fragment.selectionSet, path, context);
2704
2657
  }
2705
2658
  }
2706
- }, memo);
2707
- }
2708
- function addAccessorWarning(data, value, fieldName, path, context) {
2709
- if (value === void 0) {
2710
- return;
2659
+ if (selection.kind === graphql.Kind.INLINE_FRAGMENT &&
2660
+ (!selection.typeCondition ||
2661
+ context.cache.fragmentMatches(selection, data.__typename))) {
2662
+ value = maskSelectionSet(data, selection.selectionSet, context, migration, path);
2663
+ }
2664
+ if (selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
2665
+ var fragmentName = selection.name.value;
2666
+ var fragment = context.fragmentMap[fragmentName] ||
2667
+ (context.fragmentMap[fragmentName] =
2668
+ context.cache.lookupFragment(fragmentName));
2669
+ invariant(fragment, 41, fragmentName);
2670
+ var mode = getFragmentMaskMode(selection);
2671
+ if (mode !== "mask") {
2672
+ value = maskSelectionSet(data, fragment.selectionSet, context, mode === "migrate", path);
2673
+ }
2674
+ }
2675
+ if (knownChanged.has(value)) {
2676
+ knownChanged.add(memo);
2677
+ }
2711
2678
  }
2679
+ if ("__typename" in data && !("__typename" in memo)) {
2680
+ memo.__typename = data.__typename;
2681
+ }
2682
+ if (Object.keys(memo).length !== Object.keys(data).length) {
2683
+ knownChanged.add(memo);
2684
+ }
2685
+ return knownChanged.has(memo) ? memo : data;
2686
+ }
2687
+ function getAccessorWarningDescriptor(fieldName, value, path, operationName, operationType) {
2712
2688
  var getValue = function () {
2713
2689
  if (disableWarningsSlot.getValue()) {
2714
2690
  return value;
2715
2691
  }
2716
- globalThis.__DEV__ !== false && invariant.warn(42, context.operationName ?
2717
- "".concat(context.operationType, " '").concat(context.operationName, "'")
2718
- : "anonymous ".concat(context.operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
2692
+ globalThis.__DEV__ !== false && invariant.warn(42, operationName ?
2693
+ "".concat(operationType, " '").concat(operationName, "'")
2694
+ : "anonymous ".concat(operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
2719
2695
  getValue = function () { return value; };
2720
2696
  return value;
2721
2697
  };
2722
- Object.defineProperty(data, fieldName, {
2698
+ return {
2723
2699
  get: function () {
2724
2700
  return getValue();
2725
2701
  },
2726
- set: function (value) {
2727
- getValue = function () { return value; };
2702
+ set: function (newValue) {
2703
+ getValue = function () { return newValue; };
2728
2704
  },
2729
2705
  enumerable: true,
2730
2706
  configurable: true,
2731
- });
2707
+ };
2732
2708
  }
2733
2709
  var issuedWarning = false;
2734
2710
  function warnOnImproperCacheImplementation() {
@@ -8566,10 +8542,22 @@ function _useFragment(options) {
8566
8542
  var client = useApolloClient(options.client);
8567
8543
  var cache = client.cache;
8568
8544
  var from = options.from, rest = tslib.__rest(options, ["from"]);
8569
- var id = React__namespace.useMemo(function () { return (typeof from === "string" ? from : cache.identify(from)); }, [cache, from]);
8545
+ var id = React__namespace.useMemo(function () {
8546
+ return typeof from === "string" ? from
8547
+ : from === null ? null
8548
+ : cache.identify(from);
8549
+ }, [cache, from]);
8570
8550
  var stableOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, rest), { from: id })); }, [rest, id]);
8571
8551
  var diff = React__namespace.useMemo(function () {
8572
8552
  var fragment = stableOptions.fragment, fragmentName = stableOptions.fragmentName, from = stableOptions.from, _a = stableOptions.optimistic, optimistic = _a === void 0 ? true : _a;
8553
+ if (from === null) {
8554
+ return {
8555
+ result: diffToResult({
8556
+ result: {},
8557
+ complete: false,
8558
+ }),
8559
+ };
8560
+ }
8573
8561
  var cache = client.cache;
8574
8562
  var diff = cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }));
8575
8563
  return {
@@ -8583,17 +8571,19 @@ function _useFragment(options) {
8583
8571
  var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
8584
8572
  return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
8585
8573
  var lastTimeout = 0;
8586
- var subscription = client.watchFragment(stableOptions).subscribe({
8587
- next: function (result) {
8588
- if (equal__default(result, diff.result))
8589
- return;
8590
- diff.result = result;
8591
- clearTimeout(lastTimeout);
8592
- lastTimeout = setTimeout(forceUpdate);
8593
- },
8594
- });
8574
+ var subscription = stableOptions.from === null ?
8575
+ null
8576
+ : client.watchFragment(stableOptions).subscribe({
8577
+ next: function (result) {
8578
+ if (equal__default(result, diff.result))
8579
+ return;
8580
+ diff.result = result;
8581
+ clearTimeout(lastTimeout);
8582
+ lastTimeout = setTimeout(forceUpdate);
8583
+ },
8584
+ });
8595
8585
  return function () {
8596
- subscription.unsubscribe();
8586
+ subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
8597
8587
  clearTimeout(lastTimeout);
8598
8588
  };
8599
8589
  }, [client, stableOptions, diff]), getSnapshot, getSnapshot);