@apollo/client 3.12.0-rc.0 → 3.12.0-rc.1
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.
- package/.changeset/brown-readers-smash.md +5 -0
- package/.changeset/gorgeous-zebras-confess.md +5 -0
- package/.changeset/long-zoos-ring.md +5 -0
- package/.changeset/nice-countries-share.md +5 -0
- package/.changeset/pre.json +7 -1
- package/.changeset/slimy-points-end.md +5 -0
- package/.changeset/small-bears-confess.md +5 -0
- package/CHANGELOG.md +18 -0
- package/apollo-client.cjs +56 -18
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +30 -6
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +30 -6
- package/core/core.cjs +31 -7
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +31 -7
- package/core/masking.js +30 -6
- package/core/masking.js.map +1 -1
- package/dev/dev.cjs +1 -1
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +1 -1
- package/masking/internal/types.d.ts +2 -2
- package/masking/internal/types.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/hooks.cjs +25 -11
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +25 -11
- package/react/hooks/useFragment.d.ts +1 -1
- package/react/hooks/useFragment.js +33 -19
- package/react/hooks/useFragment.js.map +1 -1
- package/react/internal/internal.cjs +1 -1
- package/react/internal/internal.cjs.map +1 -1
- package/react/internal/internal.cjs.native.js +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/version.js +1 -1
package/.changeset/pre.json
CHANGED
|
@@ -5,11 +5,17 @@
|
|
|
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",
|
|
11
13
|
"kind-toys-tie",
|
|
14
|
+
"long-zoos-ring",
|
|
12
15
|
"nasty-camels-pay",
|
|
13
|
-
"nervous-owls-hear"
|
|
16
|
+
"nervous-owls-hear",
|
|
17
|
+
"nice-countries-share",
|
|
18
|
+
"slimy-points-end",
|
|
19
|
+
"small-bears-confess"
|
|
14
20
|
]
|
|
15
21
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 3.12.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#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
|
|
12
|
+
|
|
13
|
+
- [#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.
|
|
14
|
+
|
|
15
|
+
- [#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.
|
|
16
|
+
|
|
17
|
+
- [#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.
|
|
18
|
+
|
|
19
|
+
- [#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.
|
|
20
|
+
|
|
3
21
|
## 3.12.0-rc.0
|
|
4
22
|
|
|
5
23
|
### 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.
|
|
34
|
+
var version = "3.12.0-rc.1";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -2602,7 +2602,10 @@ function maskSelectionSet(data, selectionSet, context, path) {
|
|
|
2602
2602
|
});
|
|
2603
2603
|
return [changed_1 ? masked : data, changed_1];
|
|
2604
2604
|
}
|
|
2605
|
-
var result = selectionSet.selections
|
|
2605
|
+
var result = selectionSet.selections
|
|
2606
|
+
.concat()
|
|
2607
|
+
.sort(sortFragmentsLast)
|
|
2608
|
+
.reduce(function (_a, selection) {
|
|
2606
2609
|
var memo = _a[0], changed = _a[1];
|
|
2607
2610
|
switch (selection.kind) {
|
|
2608
2611
|
case graphql.Kind.FIELD: {
|
|
@@ -2612,7 +2615,9 @@ function maskSelectionSet(data, selectionSet, context, path) {
|
|
|
2612
2615
|
if (memo[keyName] === void 0) {
|
|
2613
2616
|
delete memo[keyName];
|
|
2614
2617
|
}
|
|
2615
|
-
if (keyName in memo &&
|
|
2618
|
+
if (keyName in memo &&
|
|
2619
|
+
childSelectionSet &&
|
|
2620
|
+
data[keyName] !== null) {
|
|
2616
2621
|
var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
|
|
2617
2622
|
if (childChanged ||
|
|
2618
2623
|
Object.keys(masked).length !== Object.keys(data[keyName]).length) {
|
|
@@ -2667,20 +2672,29 @@ function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
|
|
|
2667
2672
|
return addFieldAccessorWarnings(memo[index] || Object.create(null), item, selectionSetNode, "".concat(path, "[").concat(index, "]"), context);
|
|
2668
2673
|
});
|
|
2669
2674
|
}
|
|
2670
|
-
return selectionSetNode.selections
|
|
2675
|
+
return selectionSetNode.selections
|
|
2676
|
+
.concat()
|
|
2677
|
+
.sort(sortFragmentsLast)
|
|
2678
|
+
.reduce(function (memo, selection) {
|
|
2671
2679
|
switch (selection.kind) {
|
|
2672
2680
|
case graphql.Kind.FIELD: {
|
|
2673
2681
|
var keyName = resultKeyNameFromField(selection);
|
|
2674
2682
|
var childSelectionSet = selection.selectionSet;
|
|
2675
|
-
if (keyName in memo) {
|
|
2683
|
+
if (keyName in memo && !childSelectionSet) {
|
|
2676
2684
|
return memo;
|
|
2677
2685
|
}
|
|
2678
2686
|
var value = data[keyName];
|
|
2679
2687
|
if (childSelectionSet) {
|
|
2680
|
-
value = addFieldAccessorWarnings(memo[keyName] ||
|
|
2688
|
+
value = addFieldAccessorWarnings(memo[keyName] ||
|
|
2689
|
+
(Array.isArray(data[keyName]) ? [] : Object.create(null)), data[keyName], childSelectionSet, "".concat(path, ".").concat(keyName), context);
|
|
2681
2690
|
}
|
|
2682
2691
|
if (globalThis.__DEV__ !== false) {
|
|
2683
|
-
|
|
2692
|
+
if (keyName in memo) {
|
|
2693
|
+
memo[keyName] = value;
|
|
2694
|
+
}
|
|
2695
|
+
else {
|
|
2696
|
+
addAccessorWarning(memo, value, keyName, path, context);
|
|
2697
|
+
}
|
|
2684
2698
|
}
|
|
2685
2699
|
if (!(globalThis.__DEV__ !== false)) {
|
|
2686
2700
|
memo[keyName] = data[keyName];
|
|
@@ -2688,6 +2702,10 @@ function addFieldAccessorWarnings(memo, data, selectionSetNode, path, context) {
|
|
|
2688
2702
|
return memo;
|
|
2689
2703
|
}
|
|
2690
2704
|
case graphql.Kind.INLINE_FRAGMENT: {
|
|
2705
|
+
if (selection.typeCondition &&
|
|
2706
|
+
!context.cache.fragmentMatches(selection, data.__typename)) {
|
|
2707
|
+
return memo;
|
|
2708
|
+
}
|
|
2691
2709
|
return addFieldAccessorWarnings(memo, data, selection.selectionSet, path, context);
|
|
2692
2710
|
}
|
|
2693
2711
|
case graphql.Kind.FRAGMENT_SPREAD: {
|
|
@@ -2737,6 +2755,12 @@ function warnOnImproperCacheImplementation() {
|
|
|
2737
2755
|
globalThis.__DEV__ !== false && invariant.warn(43);
|
|
2738
2756
|
}
|
|
2739
2757
|
}
|
|
2758
|
+
function sortFragmentsLast(a, b) {
|
|
2759
|
+
if (a.kind === b.kind) {
|
|
2760
|
+
return 0;
|
|
2761
|
+
}
|
|
2762
|
+
return a.kind === graphql.Kind.FRAGMENT_SPREAD ? 1 : -1;
|
|
2763
|
+
}
|
|
2740
2764
|
|
|
2741
2765
|
var ApolloCache = (function () {
|
|
2742
2766
|
function ApolloCache() {
|
|
@@ -8566,10 +8590,22 @@ function _useFragment(options) {
|
|
|
8566
8590
|
var client = useApolloClient(options.client);
|
|
8567
8591
|
var cache = client.cache;
|
|
8568
8592
|
var from = options.from, rest = tslib.__rest(options, ["from"]);
|
|
8569
|
-
var id = React__namespace.useMemo(function () {
|
|
8593
|
+
var id = React__namespace.useMemo(function () {
|
|
8594
|
+
return typeof from === "string" ? from
|
|
8595
|
+
: from === null ? null
|
|
8596
|
+
: cache.identify(from);
|
|
8597
|
+
}, [cache, from]);
|
|
8570
8598
|
var stableOptions = useDeepMemo(function () { return (tslib.__assign(tslib.__assign({}, rest), { from: id })); }, [rest, id]);
|
|
8571
8599
|
var diff = React__namespace.useMemo(function () {
|
|
8572
8600
|
var fragment = stableOptions.fragment, fragmentName = stableOptions.fragmentName, from = stableOptions.from, _a = stableOptions.optimistic, optimistic = _a === void 0 ? true : _a;
|
|
8601
|
+
if (from === null) {
|
|
8602
|
+
return {
|
|
8603
|
+
result: diffToResult({
|
|
8604
|
+
result: {},
|
|
8605
|
+
complete: false,
|
|
8606
|
+
}),
|
|
8607
|
+
};
|
|
8608
|
+
}
|
|
8573
8609
|
var cache = client.cache;
|
|
8574
8610
|
var diff = cache.diff(tslib.__assign(tslib.__assign({}, stableOptions), { returnPartialData: true, id: from, query: cache["getFragmentDoc"](fragment, fragmentName), optimistic: optimistic }));
|
|
8575
8611
|
return {
|
|
@@ -8583,17 +8619,19 @@ function _useFragment(options) {
|
|
|
8583
8619
|
var getSnapshot = React__namespace.useCallback(function () { return diff.result; }, [diff]);
|
|
8584
8620
|
return useSyncExternalStore(React__namespace.useCallback(function (forceUpdate) {
|
|
8585
8621
|
var lastTimeout = 0;
|
|
8586
|
-
var subscription =
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8622
|
+
var subscription = stableOptions.from === null ?
|
|
8623
|
+
null
|
|
8624
|
+
: client.watchFragment(stableOptions).subscribe({
|
|
8625
|
+
next: function (result) {
|
|
8626
|
+
if (equal__default(result, diff.result))
|
|
8627
|
+
return;
|
|
8628
|
+
diff.result = result;
|
|
8629
|
+
clearTimeout(lastTimeout);
|
|
8630
|
+
lastTimeout = setTimeout(forceUpdate);
|
|
8631
|
+
},
|
|
8632
|
+
});
|
|
8595
8633
|
return function () {
|
|
8596
|
-
subscription.unsubscribe();
|
|
8634
|
+
subscription === null || subscription === void 0 ? void 0 : subscription.unsubscribe();
|
|
8597
8635
|
clearTimeout(lastTimeout);
|
|
8598
8636
|
};
|
|
8599
8637
|
}, [client, stableOptions, diff]), getSnapshot, getSnapshot);
|