@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.
- package/.changeset/brown-readers-smash.md +5 -0
- package/.changeset/gorgeous-zebras-confess.md +5 -0
- package/.changeset/itchy-penguins-worry.md +5 -0
- package/.changeset/long-zoos-ring.md +5 -0
- package/.changeset/mean-bottles-travel.md +5 -0
- package/.changeset/nice-countries-share.md +5 -0
- package/.changeset/pre.json +10 -1
- package/.changeset/slimy-points-end.md +5 -0
- package/.changeset/small-bears-confess.md +5 -0
- package/.changeset/wicked-pans-appear.md +5 -0
- package/CHANGELOG.md +28 -0
- package/apollo-client.cjs +128 -138
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +98 -119
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +98 -119
- package/core/core.cjs +103 -127
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +103 -127
- package/core/masking.js +112 -136
- 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/core/core.cjs.native.js
CHANGED
|
@@ -21,7 +21,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
21
21
|
|
|
22
22
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
23
23
|
|
|
24
|
-
var version = "3.12.0-rc.
|
|
24
|
+
var version = "3.12.0-rc.2";
|
|
25
25
|
|
|
26
26
|
function isNonNullObject(obj) {
|
|
27
27
|
return obj !== null && typeof obj === "object";
|
|
@@ -1074,6 +1074,8 @@ function shouldWriteResult(result, errorPolicy) {
|
|
|
1074
1074
|
return writeWithErrors;
|
|
1075
1075
|
}
|
|
1076
1076
|
|
|
1077
|
+
var MapImpl = utilities.canUseWeakMap ? WeakMap : Map;
|
|
1078
|
+
var SetImpl = utilities.canUseWeakSet ? WeakSet : Set;
|
|
1077
1079
|
var disableWarningsSlot = new optimism.Slot();
|
|
1078
1080
|
function maskOperation(data, document, cache) {
|
|
1079
1081
|
var _a;
|
|
@@ -1088,17 +1090,14 @@ function maskOperation(data, document, cache) {
|
|
|
1088
1090
|
if (data == null) {
|
|
1089
1091
|
return data;
|
|
1090
1092
|
}
|
|
1091
|
-
|
|
1093
|
+
return maskDefinition(data, definition.selectionSet, {
|
|
1092
1094
|
operationType: definition.operation,
|
|
1093
1095
|
operationName: (_a = definition.name) === null || _a === void 0 ? void 0 : _a.value,
|
|
1094
1096
|
fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(document)),
|
|
1095
1097
|
cache: cache,
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
disableWarningsSlot.withValue(true, utilities.maybeDeepFreeze, [masked]);
|
|
1100
|
-
}
|
|
1101
|
-
return changed ? masked : data;
|
|
1098
|
+
mutableTargets: new MapImpl(),
|
|
1099
|
+
knownChanged: new SetImpl(),
|
|
1100
|
+
});
|
|
1102
1101
|
}
|
|
1103
1102
|
function maskFragment(data, document, cache, fragmentName) {
|
|
1104
1103
|
if (!cache.fragmentMatches) {
|
|
@@ -1122,158 +1121,135 @@ function maskFragment(data, document, cache, fragmentName) {
|
|
|
1122
1121
|
if (equal.equal(data, {})) {
|
|
1123
1122
|
return data;
|
|
1124
1123
|
}
|
|
1125
|
-
|
|
1124
|
+
return maskDefinition(data, fragment.selectionSet, {
|
|
1126
1125
|
operationType: "fragment",
|
|
1127
1126
|
operationName: fragment.name.value,
|
|
1128
1127
|
fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(document)),
|
|
1129
1128
|
cache: cache,
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1129
|
+
mutableTargets: new MapImpl(),
|
|
1130
|
+
knownChanged: new SetImpl(),
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
function maskDefinition(data, selectionSet, context) {
|
|
1134
|
+
return disableWarningsSlot.withValue(true, function () {
|
|
1135
|
+
var masked = maskSelectionSet(data, selectionSet, context, false);
|
|
1136
|
+
if (Object.isFrozen(data)) {
|
|
1137
|
+
utilities.maybeDeepFreeze(masked);
|
|
1138
|
+
}
|
|
1139
|
+
return masked;
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
function getMutableTarget(data, mutableTargets) {
|
|
1143
|
+
if (mutableTargets.has(data)) {
|
|
1144
|
+
return mutableTargets.get(data);
|
|
1134
1145
|
}
|
|
1135
|
-
|
|
1146
|
+
var mutableTarget = Array.isArray(data) ? [] : Object.create(null);
|
|
1147
|
+
mutableTargets.set(data, mutableTarget);
|
|
1148
|
+
return mutableTarget;
|
|
1136
1149
|
}
|
|
1137
|
-
function maskSelectionSet(data, selectionSet, context, path) {
|
|
1150
|
+
function maskSelectionSet(data, selectionSet, context, migration, path) {
|
|
1151
|
+
var _a;
|
|
1152
|
+
var knownChanged = context.knownChanged;
|
|
1138
1153
|
if (Array.isArray(data)) {
|
|
1139
|
-
var
|
|
1140
|
-
var
|
|
1154
|
+
var target = getMutableTarget(data, context.mutableTargets);
|
|
1155
|
+
for (var _i = 0, _b = Array.from(data.entries()); _i < _b.length; _i++) {
|
|
1156
|
+
var _c = _b[_i], index = _c[0], item = _c[1];
|
|
1141
1157
|
if (item === null) {
|
|
1142
|
-
|
|
1158
|
+
target[index] = null;
|
|
1159
|
+
continue;
|
|
1143
1160
|
}
|
|
1144
|
-
var
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
});
|
|
1148
|
-
return [changed_1 ? masked : data, changed_1];
|
|
1149
|
-
}
|
|
1150
|
-
var result = selectionSet.selections.reduce(function (_a, selection) {
|
|
1151
|
-
var memo = _a[0], changed = _a[1];
|
|
1152
|
-
switch (selection.kind) {
|
|
1153
|
-
case graphql.Kind.FIELD: {
|
|
1154
|
-
var keyName = utilities.resultKeyNameFromField(selection);
|
|
1155
|
-
var childSelectionSet = selection.selectionSet;
|
|
1156
|
-
memo[keyName] = data[keyName];
|
|
1157
|
-
if (memo[keyName] === void 0) {
|
|
1158
|
-
delete memo[keyName];
|
|
1159
|
-
}
|
|
1160
|
-
if (keyName in memo && childSelectionSet && data[keyName] !== null) {
|
|
1161
|
-
var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
|
|
1162
|
-
if (childChanged ||
|
|
1163
|
-
Object.keys(masked).length !== Object.keys(data[keyName]).length) {
|
|
1164
|
-
memo[keyName] = masked;
|
|
1165
|
-
changed = true;
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
return [memo, changed];
|
|
1169
|
-
}
|
|
1170
|
-
case graphql.Kind.INLINE_FRAGMENT: {
|
|
1171
|
-
if (selection.typeCondition &&
|
|
1172
|
-
!context.cache.fragmentMatches(selection, data.__typename)) {
|
|
1173
|
-
return [memo, changed];
|
|
1174
|
-
}
|
|
1175
|
-
var _c = maskSelectionSet(data, selection.selectionSet, context, path), fragmentData = _c[0], childChanged = _c[1];
|
|
1176
|
-
return [
|
|
1177
|
-
tslib.__assign(tslib.__assign({}, memo), fragmentData),
|
|
1178
|
-
changed || childChanged,
|
|
1179
|
-
];
|
|
1180
|
-
}
|
|
1181
|
-
case graphql.Kind.FRAGMENT_SPREAD: {
|
|
1182
|
-
var fragmentName = selection.name.value;
|
|
1183
|
-
var fragment = context.fragmentMap[fragmentName] ||
|
|
1184
|
-
(context.fragmentMap[fragmentName] =
|
|
1185
|
-
context.cache.lookupFragment(fragmentName));
|
|
1186
|
-
globals.invariant(fragment, 41, fragmentName);
|
|
1187
|
-
var mode = utilities.getFragmentMaskMode(selection);
|
|
1188
|
-
if (mode === "mask") {
|
|
1189
|
-
return [memo, true];
|
|
1190
|
-
}
|
|
1191
|
-
if (globalThis.__DEV__ !== false) {
|
|
1192
|
-
if (mode === "migrate") {
|
|
1193
|
-
return [
|
|
1194
|
-
addFieldAccessorWarnings(memo, data, fragment.selectionSet, path || "", context),
|
|
1195
|
-
true,
|
|
1196
|
-
];
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
var _d = maskSelectionSet(data, fragment.selectionSet, context, path), fragmentData = _d[0], changed_2 = _d[1];
|
|
1200
|
-
return [tslib.__assign(tslib.__assign({}, memo), fragmentData), changed_2];
|
|
1161
|
+
var masked = maskSelectionSet(item, selectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0);
|
|
1162
|
+
if (knownChanged.has(masked)) {
|
|
1163
|
+
knownChanged.add(target);
|
|
1201
1164
|
}
|
|
1165
|
+
target[index] = masked;
|
|
1202
1166
|
}
|
|
1203
|
-
|
|
1204
|
-
if (data && "__typename" in data && !("__typename" in result[0])) {
|
|
1205
|
-
result[0].__typename = data.__typename;
|
|
1167
|
+
return knownChanged.has(target) ? target : data;
|
|
1206
1168
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
value = addFieldAccessorWarnings(memo[keyName] || Object.create(null), data[keyName], childSelectionSet, "".concat(path, ".").concat(keyName), context);
|
|
1226
|
-
}
|
|
1227
|
-
if (globalThis.__DEV__ !== false) {
|
|
1228
|
-
addAccessorWarning(memo, value, keyName, path, context);
|
|
1229
|
-
}
|
|
1230
|
-
if (!(globalThis.__DEV__ !== false)) {
|
|
1231
|
-
memo[keyName] = data[keyName];
|
|
1169
|
+
var memo = getMutableTarget(data, context.mutableTargets);
|
|
1170
|
+
for (var _d = 0, _e = selectionSet.selections; _d < _e.length; _d++) {
|
|
1171
|
+
var selection = _e[_d];
|
|
1172
|
+
var value = void 0;
|
|
1173
|
+
if (migration) {
|
|
1174
|
+
knownChanged.add(memo);
|
|
1175
|
+
}
|
|
1176
|
+
if (selection.kind === graphql.Kind.FIELD) {
|
|
1177
|
+
var keyName = utilities.resultKeyNameFromField(selection);
|
|
1178
|
+
var childSelectionSet = selection.selectionSet;
|
|
1179
|
+
value = memo[keyName] || data[keyName];
|
|
1180
|
+
if (value === void 0) {
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
if (childSelectionSet && value !== null) {
|
|
1184
|
+
var masked = maskSelectionSet(data[keyName], childSelectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0);
|
|
1185
|
+
if (knownChanged.has(masked)) {
|
|
1186
|
+
value = masked;
|
|
1232
1187
|
}
|
|
1233
|
-
return memo;
|
|
1234
1188
|
}
|
|
1235
|
-
|
|
1236
|
-
|
|
1189
|
+
if (!(globalThis.__DEV__ !== false)) {
|
|
1190
|
+
memo[keyName] = value;
|
|
1237
1191
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1192
|
+
if (globalThis.__DEV__ !== false) {
|
|
1193
|
+
if (migration &&
|
|
1194
|
+
keyName !== "__typename" &&
|
|
1195
|
+
!((_a = Object.getOwnPropertyDescriptor(memo, keyName)) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
1196
|
+
Object.defineProperty(memo, keyName, getAccessorWarningDescriptor(keyName, value, path || "", context.operationName, context.operationType));
|
|
1243
1197
|
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1198
|
+
else {
|
|
1199
|
+
delete memo[keyName];
|
|
1200
|
+
memo[keyName] = value;
|
|
1247
1201
|
}
|
|
1248
|
-
return addFieldAccessorWarnings(memo, data, fragment.selectionSet, path, context);
|
|
1249
1202
|
}
|
|
1250
1203
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1204
|
+
if (selection.kind === graphql.Kind.INLINE_FRAGMENT &&
|
|
1205
|
+
(!selection.typeCondition ||
|
|
1206
|
+
context.cache.fragmentMatches(selection, data.__typename))) {
|
|
1207
|
+
value = maskSelectionSet(data, selection.selectionSet, context, migration, path);
|
|
1208
|
+
}
|
|
1209
|
+
if (selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
|
|
1210
|
+
var fragmentName = selection.name.value;
|
|
1211
|
+
var fragment = context.fragmentMap[fragmentName] ||
|
|
1212
|
+
(context.fragmentMap[fragmentName] =
|
|
1213
|
+
context.cache.lookupFragment(fragmentName));
|
|
1214
|
+
globals.invariant(fragment, 41, fragmentName);
|
|
1215
|
+
var mode = utilities.getFragmentMaskMode(selection);
|
|
1216
|
+
if (mode !== "mask") {
|
|
1217
|
+
value = maskSelectionSet(data, fragment.selectionSet, context, mode === "migrate", path);
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
if (knownChanged.has(value)) {
|
|
1221
|
+
knownChanged.add(memo);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
if ("__typename" in data && !("__typename" in memo)) {
|
|
1225
|
+
memo.__typename = data.__typename;
|
|
1256
1226
|
}
|
|
1227
|
+
if (Object.keys(memo).length !== Object.keys(data).length) {
|
|
1228
|
+
knownChanged.add(memo);
|
|
1229
|
+
}
|
|
1230
|
+
return knownChanged.has(memo) ? memo : data;
|
|
1231
|
+
}
|
|
1232
|
+
function getAccessorWarningDescriptor(fieldName, value, path, operationName, operationType) {
|
|
1257
1233
|
var getValue = function () {
|
|
1258
1234
|
if (disableWarningsSlot.getValue()) {
|
|
1259
1235
|
return value;
|
|
1260
1236
|
}
|
|
1261
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(42,
|
|
1262
|
-
"".concat(
|
|
1263
|
-
: "anonymous ".concat(
|
|
1237
|
+
globalThis.__DEV__ !== false && globals.invariant.warn(42, operationName ?
|
|
1238
|
+
"".concat(operationType, " '").concat(operationName, "'")
|
|
1239
|
+
: "anonymous ".concat(operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
|
|
1264
1240
|
getValue = function () { return value; };
|
|
1265
1241
|
return value;
|
|
1266
1242
|
};
|
|
1267
|
-
|
|
1243
|
+
return {
|
|
1268
1244
|
get: function () {
|
|
1269
1245
|
return getValue();
|
|
1270
1246
|
},
|
|
1271
|
-
set: function (
|
|
1272
|
-
getValue = function () { return
|
|
1247
|
+
set: function (newValue) {
|
|
1248
|
+
getValue = function () { return newValue; };
|
|
1273
1249
|
},
|
|
1274
1250
|
enumerable: true,
|
|
1275
1251
|
configurable: true,
|
|
1276
|
-
}
|
|
1252
|
+
};
|
|
1277
1253
|
}
|
|
1278
1254
|
var issuedWarning = false;
|
|
1279
1255
|
function warnOnImproperCacheImplementation() {
|
package/core/masking.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { __assign } from "tslib";
|
|
2
1
|
import { Kind } from "graphql";
|
|
3
|
-
import { createFragmentMap, resultKeyNameFromField, getFragmentDefinitions, getFragmentMaskMode, getOperationDefinition, maybeDeepFreeze, } from "../utilities/index.js";
|
|
2
|
+
import { createFragmentMap, resultKeyNameFromField, getFragmentDefinitions, getFragmentMaskMode, getOperationDefinition, maybeDeepFreeze, canUseWeakMap, canUseWeakSet, } from "../utilities/index.js";
|
|
4
3
|
import { invariant } from "../utilities/globals/index.js";
|
|
5
4
|
import { equal } from "@wry/equality";
|
|
6
5
|
import { Slot } from "optimism";
|
|
6
|
+
var MapImpl = canUseWeakMap ? WeakMap : Map;
|
|
7
|
+
var SetImpl = canUseWeakSet ? WeakSet : Set;
|
|
7
8
|
// Contextual slot that allows us to disable accessor warnings on fields when in
|
|
8
9
|
// migrate mode.
|
|
9
10
|
export var disableWarningsSlot = new Slot();
|
|
@@ -21,17 +22,14 @@ export function maskOperation(data, document, cache) {
|
|
|
21
22
|
// Maintain the original `null` or `undefined` value
|
|
22
23
|
return data;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
return maskDefinition(data, definition.selectionSet, {
|
|
25
26
|
operationType: definition.operation,
|
|
26
27
|
operationName: (_a = definition.name) === null || _a === void 0 ? void 0 : _a.value,
|
|
27
28
|
fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
|
|
28
29
|
cache: cache,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
disableWarningsSlot.withValue(true, maybeDeepFreeze, [masked]);
|
|
33
|
-
}
|
|
34
|
-
return changed ? masked : data;
|
|
30
|
+
mutableTargets: new MapImpl(),
|
|
31
|
+
knownChanged: new SetImpl(),
|
|
32
|
+
});
|
|
35
33
|
}
|
|
36
34
|
export function maskFragment(data, document, cache, fragmentName) {
|
|
37
35
|
if (!cache.fragmentMatches) {
|
|
@@ -59,166 +57,144 @@ export function maskFragment(data, document, cache, fragmentName) {
|
|
|
59
57
|
// used from watchFragment.
|
|
60
58
|
return data;
|
|
61
59
|
}
|
|
62
|
-
|
|
60
|
+
return maskDefinition(data, fragment.selectionSet, {
|
|
63
61
|
operationType: "fragment",
|
|
64
62
|
operationName: fragment.name.value,
|
|
65
63
|
fragmentMap: createFragmentMap(getFragmentDefinitions(document)),
|
|
66
64
|
cache: cache,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
mutableTargets: new MapImpl(),
|
|
66
|
+
knownChanged: new SetImpl(),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function maskDefinition(data, selectionSet, context) {
|
|
70
|
+
return disableWarningsSlot.withValue(true, function () {
|
|
71
|
+
var masked = maskSelectionSet(data, selectionSet, context, false);
|
|
72
|
+
if (Object.isFrozen(data)) {
|
|
73
|
+
maybeDeepFreeze(masked);
|
|
74
|
+
}
|
|
75
|
+
return masked;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function getMutableTarget(data, mutableTargets) {
|
|
79
|
+
if (mutableTargets.has(data)) {
|
|
80
|
+
return mutableTargets.get(data);
|
|
71
81
|
}
|
|
72
|
-
|
|
82
|
+
var mutableTarget = Array.isArray(data) ? [] : Object.create(null);
|
|
83
|
+
mutableTargets.set(data, mutableTarget);
|
|
84
|
+
return mutableTarget;
|
|
73
85
|
}
|
|
74
|
-
function maskSelectionSet(data, selectionSet, context, path) {
|
|
86
|
+
function maskSelectionSet(data, selectionSet, context, migration, path) {
|
|
87
|
+
var _a;
|
|
88
|
+
var knownChanged = context.knownChanged;
|
|
75
89
|
if (Array.isArray(data)) {
|
|
76
|
-
var
|
|
77
|
-
var
|
|
90
|
+
var target = getMutableTarget(data, context.mutableTargets);
|
|
91
|
+
for (var _i = 0, _b = Array.from(data.entries()); _i < _b.length; _i++) {
|
|
92
|
+
var _c = _b[_i], index = _c[0], item = _c[1];
|
|
78
93
|
if (item === null) {
|
|
79
|
-
|
|
94
|
+
target[index] = null;
|
|
95
|
+
continue;
|
|
80
96
|
}
|
|
81
|
-
var
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
return [changed_1 ? masked : data, changed_1];
|
|
86
|
-
}
|
|
87
|
-
var result = selectionSet.selections.reduce(function (_a, selection) {
|
|
88
|
-
var memo = _a[0], changed = _a[1];
|
|
89
|
-
switch (selection.kind) {
|
|
90
|
-
case Kind.FIELD: {
|
|
91
|
-
var keyName = resultKeyNameFromField(selection);
|
|
92
|
-
var childSelectionSet = selection.selectionSet;
|
|
93
|
-
memo[keyName] = data[keyName];
|
|
94
|
-
if (memo[keyName] === void 0) {
|
|
95
|
-
delete memo[keyName];
|
|
96
|
-
}
|
|
97
|
-
if (keyName in memo && childSelectionSet && data[keyName] !== null) {
|
|
98
|
-
var _b = maskSelectionSet(data[keyName], childSelectionSet, context, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0), masked = _b[0], childChanged = _b[1];
|
|
99
|
-
if (childChanged ||
|
|
100
|
-
// This check prevents cases where masked fields may accidentally be
|
|
101
|
-
// returned as part of this object when the fragment also selects
|
|
102
|
-
// additional fields from the same child selection.
|
|
103
|
-
Object.keys(masked).length !== Object.keys(data[keyName]).length) {
|
|
104
|
-
memo[keyName] = masked;
|
|
105
|
-
changed = true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return [memo, changed];
|
|
109
|
-
}
|
|
110
|
-
case Kind.INLINE_FRAGMENT: {
|
|
111
|
-
if (selection.typeCondition &&
|
|
112
|
-
!context.cache.fragmentMatches(selection, data.__typename)) {
|
|
113
|
-
return [memo, changed];
|
|
114
|
-
}
|
|
115
|
-
var _c = maskSelectionSet(data, selection.selectionSet, context, path), fragmentData = _c[0], childChanged = _c[1];
|
|
116
|
-
return [
|
|
117
|
-
__assign(__assign({}, memo), fragmentData),
|
|
118
|
-
changed || childChanged,
|
|
119
|
-
];
|
|
120
|
-
}
|
|
121
|
-
case Kind.FRAGMENT_SPREAD: {
|
|
122
|
-
var fragmentName = selection.name.value;
|
|
123
|
-
var fragment = context.fragmentMap[fragmentName] ||
|
|
124
|
-
(context.fragmentMap[fragmentName] =
|
|
125
|
-
context.cache.lookupFragment(fragmentName));
|
|
126
|
-
invariant(fragment, 41, fragmentName);
|
|
127
|
-
var mode = getFragmentMaskMode(selection);
|
|
128
|
-
if (mode === "mask") {
|
|
129
|
-
return [memo, true];
|
|
130
|
-
}
|
|
131
|
-
if (globalThis.__DEV__ !== false) {
|
|
132
|
-
if (mode === "migrate") {
|
|
133
|
-
return [
|
|
134
|
-
addFieldAccessorWarnings(memo, data, fragment.selectionSet, path || "", context),
|
|
135
|
-
true,
|
|
136
|
-
];
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
var _d = maskSelectionSet(data, fragment.selectionSet, context, path), fragmentData = _d[0], changed_2 = _d[1];
|
|
140
|
-
return [__assign(__assign({}, memo), fragmentData), changed_2];
|
|
97
|
+
var masked = maskSelectionSet(item, selectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0);
|
|
98
|
+
if (knownChanged.has(masked)) {
|
|
99
|
+
knownChanged.add(target);
|
|
141
100
|
}
|
|
101
|
+
target[index] = masked;
|
|
142
102
|
}
|
|
143
|
-
|
|
144
|
-
if (data && "__typename" in data && !("__typename" in result[0])) {
|
|
145
|
-
result[0].__typename = data.__typename;
|
|
103
|
+
return knownChanged.has(target) ? target : data;
|
|
146
104
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (globalThis.__DEV__ !== false) {
|
|
168
|
-
addAccessorWarning(memo, value, keyName, path, context);
|
|
169
|
-
}
|
|
170
|
-
if (!(globalThis.__DEV__ !== false)) {
|
|
171
|
-
memo[keyName] = data[keyName];
|
|
105
|
+
var memo = getMutableTarget(data, context.mutableTargets);
|
|
106
|
+
for (var _d = 0, _e = selectionSet.selections; _d < _e.length; _d++) {
|
|
107
|
+
var selection = _e[_d];
|
|
108
|
+
var value = void 0;
|
|
109
|
+
// we later want to add acessor warnings to the final result
|
|
110
|
+
// so we need a new object to add the accessor warning to
|
|
111
|
+
if (migration) {
|
|
112
|
+
knownChanged.add(memo);
|
|
113
|
+
}
|
|
114
|
+
if (selection.kind === Kind.FIELD) {
|
|
115
|
+
var keyName = resultKeyNameFromField(selection);
|
|
116
|
+
var childSelectionSet = selection.selectionSet;
|
|
117
|
+
value = memo[keyName] || data[keyName];
|
|
118
|
+
if (value === void 0) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (childSelectionSet && value !== null) {
|
|
122
|
+
var masked = maskSelectionSet(data[keyName], childSelectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0);
|
|
123
|
+
if (knownChanged.has(masked)) {
|
|
124
|
+
value = masked;
|
|
172
125
|
}
|
|
173
|
-
return memo;
|
|
174
126
|
}
|
|
175
|
-
|
|
176
|
-
|
|
127
|
+
if (!(globalThis.__DEV__ !== false)) {
|
|
128
|
+
memo[keyName] = value;
|
|
177
129
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
130
|
+
if (globalThis.__DEV__ !== false) {
|
|
131
|
+
if (migration &&
|
|
132
|
+
keyName !== "__typename" &&
|
|
133
|
+
// either the field is not present in the memo object
|
|
134
|
+
// or it has a `get` descriptor, not a `value` descriptor
|
|
135
|
+
// => it is a warning accessor and we can overwrite it
|
|
136
|
+
// with another accessor
|
|
137
|
+
!((_a = Object.getOwnPropertyDescriptor(memo, keyName)) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
138
|
+
Object.defineProperty(memo, keyName, getAccessorWarningDescriptor(keyName, value, path || "", context.operationName, context.operationType));
|
|
183
139
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
140
|
+
else {
|
|
141
|
+
delete memo[keyName];
|
|
142
|
+
memo[keyName] = value;
|
|
187
143
|
}
|
|
188
|
-
return addFieldAccessorWarnings(memo, data, fragment.selectionSet, path, context);
|
|
189
144
|
}
|
|
190
145
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
146
|
+
if (selection.kind === Kind.INLINE_FRAGMENT &&
|
|
147
|
+
(!selection.typeCondition ||
|
|
148
|
+
context.cache.fragmentMatches(selection, data.__typename))) {
|
|
149
|
+
value = maskSelectionSet(data, selection.selectionSet, context, migration, path);
|
|
150
|
+
}
|
|
151
|
+
if (selection.kind === Kind.FRAGMENT_SPREAD) {
|
|
152
|
+
var fragmentName = selection.name.value;
|
|
153
|
+
var fragment = context.fragmentMap[fragmentName] ||
|
|
154
|
+
(context.fragmentMap[fragmentName] =
|
|
155
|
+
context.cache.lookupFragment(fragmentName));
|
|
156
|
+
invariant(fragment, 41, fragmentName);
|
|
157
|
+
var mode = getFragmentMaskMode(selection);
|
|
158
|
+
if (mode !== "mask") {
|
|
159
|
+
value = maskSelectionSet(data, fragment.selectionSet, context, mode === "migrate", path);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (knownChanged.has(value)) {
|
|
163
|
+
knownChanged.add(memo);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if ("__typename" in data && !("__typename" in memo)) {
|
|
167
|
+
memo.__typename = data.__typename;
|
|
201
168
|
}
|
|
169
|
+
// This check prevents cases where masked fields may accidentally be
|
|
170
|
+
// returned as part of this object when the fragment also selects
|
|
171
|
+
// additional fields from the same child selection.
|
|
172
|
+
if (Object.keys(memo).length !== Object.keys(data).length) {
|
|
173
|
+
knownChanged.add(memo);
|
|
174
|
+
}
|
|
175
|
+
return knownChanged.has(memo) ? memo : data;
|
|
176
|
+
}
|
|
177
|
+
function getAccessorWarningDescriptor(fieldName, value, path, operationName, operationType) {
|
|
202
178
|
var getValue = function () {
|
|
203
179
|
if (disableWarningsSlot.getValue()) {
|
|
204
180
|
return value;
|
|
205
181
|
}
|
|
206
|
-
globalThis.__DEV__ !== false && invariant.warn(42,
|
|
207
|
-
"".concat(
|
|
208
|
-
: "anonymous ".concat(
|
|
182
|
+
globalThis.__DEV__ !== false && invariant.warn(42, operationName ?
|
|
183
|
+
"".concat(operationType, " '").concat(operationName, "'")
|
|
184
|
+
: "anonymous ".concat(operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
|
|
209
185
|
getValue = function () { return value; };
|
|
210
186
|
return value;
|
|
211
187
|
};
|
|
212
|
-
|
|
188
|
+
return {
|
|
213
189
|
get: function () {
|
|
214
190
|
return getValue();
|
|
215
191
|
},
|
|
216
|
-
set: function (
|
|
217
|
-
getValue = function () { return
|
|
192
|
+
set: function (newValue) {
|
|
193
|
+
getValue = function () { return newValue; };
|
|
218
194
|
},
|
|
219
195
|
enumerable: true,
|
|
220
196
|
configurable: true,
|
|
221
|
-
}
|
|
197
|
+
};
|
|
222
198
|
}
|
|
223
199
|
var issuedWarning = false;
|
|
224
200
|
function warnOnImproperCacheImplementation() {
|