@apollo/client 3.12.0-rc.3 → 3.12.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.
- package/CHANGELOG.md +66 -0
- package/README.md +2 -0
- package/apollo-client.cjs +69 -66
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +4 -165
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +4 -165
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/inmemory/policies.js +1 -1
- package/cache/inmemory/policies.js.map +1 -1
- package/config/jest/setup.js +0 -2
- package/config/jest/setup.js.map +1 -1
- package/core/QueryManager.js +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +4 -188
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +4 -188
- package/dev/dev.cjs +37 -37
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +37 -37
- package/invariantErrorCodes.js +42 -42
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/http.cjs +3 -3
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +3 -3
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/masking/__benches__/types.bench.d.ts +2 -0
- package/masking/__benches__/types.bench.js +131 -0
- package/masking/__benches__/types.bench.js.map +1 -0
- package/masking/index.d.ts +3 -0
- package/masking/index.js +3 -1
- package/masking/index.js.map +1 -1
- package/masking/internal/types.d.ts +114 -9
- package/masking/internal/types.js.map +1 -1
- package/masking/maskDefinition.d.ts +14 -0
- package/{core/masking.js → masking/maskDefinition.js} +6 -77
- package/masking/maskDefinition.js.map +1 -0
- package/masking/maskFragment.d.ts +4 -0
- package/masking/maskFragment.js +43 -0
- package/masking/maskFragment.js.map +1 -0
- package/masking/maskOperation.d.ts +4 -0
- package/masking/maskOperation.js +29 -0
- package/masking/maskOperation.js.map +1 -0
- package/masking/masking.cjs +202 -0
- package/masking/masking.cjs.map +1 -1
- package/masking/masking.cjs.native.js +202 -0
- package/masking/types.d.ts +4 -4
- package/masking/types.js.map +1 -1
- package/masking/utils.d.ts +11 -0
- package/masking/utils.js +17 -0
- package/masking/utils.js.map +1 -0
- package/package.json +10 -7
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/mutation-hoc.js +3 -2
- package/react/hoc/mutation-hoc.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/testing/internal/disposables/index.d.ts +0 -1
- package/testing/internal/disposables/index.js +0 -1
- package/testing/internal/disposables/index.js.map +1 -1
- package/testing/internal/index.d.ts +4 -1
- package/testing/internal/index.js +4 -1
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/rtl/actAsync.d.ts +2 -0
- package/testing/internal/rtl/actAsync.js +21 -0
- package/testing/internal/rtl/actAsync.js.map +1 -0
- package/testing/internal/rtl/renderAsync.d.ts +9 -0
- package/testing/internal/rtl/renderAsync.js +23 -0
- package/testing/internal/rtl/renderAsync.js.map +1 -0
- package/testing/internal/rtl/renderHookAsync.d.ts +8 -0
- package/testing/internal/rtl/renderHookAsync.js +45 -0
- package/testing/internal/rtl/renderHookAsync.js.map +1 -0
- package/testing/internal/scenarios/index.d.ts +10 -0
- package/testing/internal/scenarios/index.js +9 -2
- package/testing/internal/scenarios/index.js.map +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/brown-readers-smash.md +0 -5
- package/.changeset/clean-turkeys-kick.md +0 -5
- package/.changeset/cold-apes-bow.md +0 -5
- package/.changeset/early-bobcats-eat.md +0 -5
- package/.changeset/flat-beans-knock.md +0 -15
- package/.changeset/gorgeous-zebras-confess.md +0 -5
- package/.changeset/itchy-penguins-worry.md +0 -5
- package/.changeset/kind-toys-tie.md +0 -5
- package/.changeset/long-zoos-ring.md +0 -5
- package/.changeset/mean-bottles-travel.md +0 -5
- package/.changeset/nasty-camels-pay.md +0 -36
- package/.changeset/nervous-owls-hear.md +0 -5
- package/.changeset/nice-countries-share.md +0 -5
- package/.changeset/perfect-jobs-flow.md +0 -5
- package/.changeset/pre.json +0 -26
- package/.changeset/slimy-points-end.md +0 -5
- package/.changeset/small-bears-confess.md +0 -5
- package/.changeset/wicked-pans-appear.md +0 -5
- package/core/masking.d.ts +0 -10
- package/core/masking.js.map +0 -1
- package/testing/internal/disposables/disableActWarnings.d.ts +0 -9
- package/testing/internal/disposables/disableActWarnings.js +0 -15
- package/testing/internal/disposables/disableActWarnings.js.map +0 -1
package/cache/cache.cjs
CHANGED
|
@@ -8,8 +8,9 @@ var optimism = require('optimism');
|
|
|
8
8
|
var utilities = require('../utilities');
|
|
9
9
|
var caches = require('@wry/caches');
|
|
10
10
|
var equal = require('@wry/equality');
|
|
11
|
-
var
|
|
11
|
+
var masking = require('../masking');
|
|
12
12
|
var trie = require('@wry/trie');
|
|
13
|
+
var graphql = require('graphql');
|
|
13
14
|
|
|
14
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
15
16
|
|
|
@@ -126,168 +127,6 @@ function directiveIsNonreactive(dir) {
|
|
|
126
127
|
return dir.name.value === "nonreactive";
|
|
127
128
|
}
|
|
128
129
|
|
|
129
|
-
var MapImpl = utilities.canUseWeakMap ? WeakMap : Map;
|
|
130
|
-
var SetImpl = utilities.canUseWeakSet ? WeakSet : Set;
|
|
131
|
-
var disableWarningsSlot = new optimism.Slot();
|
|
132
|
-
function maskFragment(data, document, cache, fragmentName) {
|
|
133
|
-
if (!cache.fragmentMatches) {
|
|
134
|
-
if (globalThis.__DEV__ !== false) {
|
|
135
|
-
warnOnImproperCacheImplementation();
|
|
136
|
-
}
|
|
137
|
-
return data;
|
|
138
|
-
}
|
|
139
|
-
var fragments = document.definitions.filter(function (node) {
|
|
140
|
-
return node.kind === graphql.Kind.FRAGMENT_DEFINITION;
|
|
141
|
-
});
|
|
142
|
-
if (typeof fragmentName === "undefined") {
|
|
143
|
-
globals.invariant(fragments.length === 1, 39, fragments.length);
|
|
144
|
-
fragmentName = fragments[0].name.value;
|
|
145
|
-
}
|
|
146
|
-
var fragment = fragments.find(function (fragment) { return fragment.name.value === fragmentName; });
|
|
147
|
-
globals.invariant(!!fragment, 40, fragmentName);
|
|
148
|
-
if (data == null) {
|
|
149
|
-
return data;
|
|
150
|
-
}
|
|
151
|
-
if (equal.equal(data, {})) {
|
|
152
|
-
return data;
|
|
153
|
-
}
|
|
154
|
-
return maskDefinition(data, fragment.selectionSet, {
|
|
155
|
-
operationType: "fragment",
|
|
156
|
-
operationName: fragment.name.value,
|
|
157
|
-
fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(document)),
|
|
158
|
-
cache: cache,
|
|
159
|
-
mutableTargets: new MapImpl(),
|
|
160
|
-
knownChanged: new SetImpl(),
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function maskDefinition(data, selectionSet, context) {
|
|
164
|
-
return disableWarningsSlot.withValue(true, function () {
|
|
165
|
-
var masked = maskSelectionSet(data, selectionSet, context, false);
|
|
166
|
-
if (Object.isFrozen(data)) {
|
|
167
|
-
utilities.maybeDeepFreeze(masked);
|
|
168
|
-
}
|
|
169
|
-
return masked;
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
function getMutableTarget(data, mutableTargets) {
|
|
173
|
-
if (mutableTargets.has(data)) {
|
|
174
|
-
return mutableTargets.get(data);
|
|
175
|
-
}
|
|
176
|
-
var mutableTarget = Array.isArray(data) ? [] : Object.create(null);
|
|
177
|
-
mutableTargets.set(data, mutableTarget);
|
|
178
|
-
return mutableTarget;
|
|
179
|
-
}
|
|
180
|
-
function maskSelectionSet(data, selectionSet, context, migration, path) {
|
|
181
|
-
var _a;
|
|
182
|
-
var knownChanged = context.knownChanged;
|
|
183
|
-
var memo = getMutableTarget(data, context.mutableTargets);
|
|
184
|
-
if (Array.isArray(data)) {
|
|
185
|
-
for (var _i = 0, _b = Array.from(data.entries()); _i < _b.length; _i++) {
|
|
186
|
-
var _c = _b[_i], index = _c[0], item = _c[1];
|
|
187
|
-
if (item === null) {
|
|
188
|
-
memo[index] = null;
|
|
189
|
-
continue;
|
|
190
|
-
}
|
|
191
|
-
var masked = maskSelectionSet(item, selectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", "[").concat(index, "]") : void 0);
|
|
192
|
-
if (knownChanged.has(masked)) {
|
|
193
|
-
knownChanged.add(memo);
|
|
194
|
-
}
|
|
195
|
-
memo[index] = masked;
|
|
196
|
-
}
|
|
197
|
-
return knownChanged.has(memo) ? memo : data;
|
|
198
|
-
}
|
|
199
|
-
for (var _d = 0, _e = selectionSet.selections; _d < _e.length; _d++) {
|
|
200
|
-
var selection = _e[_d];
|
|
201
|
-
var value = void 0;
|
|
202
|
-
if (migration) {
|
|
203
|
-
knownChanged.add(memo);
|
|
204
|
-
}
|
|
205
|
-
if (selection.kind === graphql.Kind.FIELD) {
|
|
206
|
-
var keyName = utilities.resultKeyNameFromField(selection);
|
|
207
|
-
var childSelectionSet = selection.selectionSet;
|
|
208
|
-
value = memo[keyName] || data[keyName];
|
|
209
|
-
if (value === void 0) {
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (childSelectionSet && value !== null) {
|
|
213
|
-
var masked = maskSelectionSet(data[keyName], childSelectionSet, context, migration, globalThis.__DEV__ !== false ? "".concat(path || "", ".").concat(keyName) : void 0);
|
|
214
|
-
if (knownChanged.has(masked)) {
|
|
215
|
-
value = masked;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (!(globalThis.__DEV__ !== false)) {
|
|
219
|
-
memo[keyName] = value;
|
|
220
|
-
}
|
|
221
|
-
if (globalThis.__DEV__ !== false) {
|
|
222
|
-
if (migration &&
|
|
223
|
-
keyName !== "__typename" &&
|
|
224
|
-
!((_a = Object.getOwnPropertyDescriptor(memo, keyName)) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
225
|
-
Object.defineProperty(memo, keyName, getAccessorWarningDescriptor(keyName, value, path || "", context.operationName, context.operationType));
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
delete memo[keyName];
|
|
229
|
-
memo[keyName] = value;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
if (selection.kind === graphql.Kind.INLINE_FRAGMENT &&
|
|
234
|
-
(!selection.typeCondition ||
|
|
235
|
-
context.cache.fragmentMatches(selection, data.__typename))) {
|
|
236
|
-
value = maskSelectionSet(data, selection.selectionSet, context, migration, path);
|
|
237
|
-
}
|
|
238
|
-
if (selection.kind === graphql.Kind.FRAGMENT_SPREAD) {
|
|
239
|
-
var fragmentName = selection.name.value;
|
|
240
|
-
var fragment = context.fragmentMap[fragmentName] ||
|
|
241
|
-
(context.fragmentMap[fragmentName] =
|
|
242
|
-
context.cache.lookupFragment(fragmentName));
|
|
243
|
-
globals.invariant(fragment, 41, fragmentName);
|
|
244
|
-
var mode = utilities.getFragmentMaskMode(selection);
|
|
245
|
-
if (mode !== "mask") {
|
|
246
|
-
value = maskSelectionSet(data, fragment.selectionSet, context, mode === "migrate", path);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
if (knownChanged.has(value)) {
|
|
250
|
-
knownChanged.add(memo);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if ("__typename" in data && !("__typename" in memo)) {
|
|
254
|
-
memo.__typename = data.__typename;
|
|
255
|
-
}
|
|
256
|
-
if (Object.keys(memo).length !== Object.keys(data).length) {
|
|
257
|
-
knownChanged.add(memo);
|
|
258
|
-
}
|
|
259
|
-
return knownChanged.has(memo) ? memo : data;
|
|
260
|
-
}
|
|
261
|
-
function getAccessorWarningDescriptor(fieldName, value, path, operationName, operationType) {
|
|
262
|
-
var getValue = function () {
|
|
263
|
-
if (disableWarningsSlot.getValue()) {
|
|
264
|
-
return value;
|
|
265
|
-
}
|
|
266
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(42, operationName ?
|
|
267
|
-
"".concat(operationType, " '").concat(operationName, "'")
|
|
268
|
-
: "anonymous ".concat(operationType), "".concat(path, ".").concat(fieldName).replace(/^\./, ""));
|
|
269
|
-
getValue = function () { return value; };
|
|
270
|
-
return value;
|
|
271
|
-
};
|
|
272
|
-
return {
|
|
273
|
-
get: function () {
|
|
274
|
-
return getValue();
|
|
275
|
-
},
|
|
276
|
-
set: function (newValue) {
|
|
277
|
-
getValue = function () { return newValue; };
|
|
278
|
-
},
|
|
279
|
-
enumerable: true,
|
|
280
|
-
configurable: true,
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
var issuedWarning = false;
|
|
284
|
-
function warnOnImproperCacheImplementation() {
|
|
285
|
-
if (!issuedWarning) {
|
|
286
|
-
issuedWarning = true;
|
|
287
|
-
globalThis.__DEV__ !== false && globals.invariant.warn(43);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
130
|
var ApolloCache = (function () {
|
|
292
131
|
function ApolloCache() {
|
|
293
132
|
this.assumeImmutableResults = false;
|
|
@@ -350,7 +189,7 @@ var ApolloCache = (function () {
|
|
|
350
189
|
return new utilities.Observable(function (observer) {
|
|
351
190
|
return _this.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
|
|
352
191
|
var data = dataMasking ?
|
|
353
|
-
maskFragment(diff.result, fragment, _this, fragmentName)
|
|
192
|
+
masking.maskFragment(diff.result, fragment, _this, fragmentName)
|
|
354
193
|
: diff.result;
|
|
355
194
|
if (
|
|
356
195
|
latestDiff &&
|
|
@@ -1634,7 +1473,7 @@ var Policies = (function () {
|
|
|
1634
1473
|
var id;
|
|
1635
1474
|
var policy = typename && this.getTypePolicy(typename);
|
|
1636
1475
|
var keyFn = (policy && policy.keyFn) || this.config.dataIdFromObject;
|
|
1637
|
-
disableWarningsSlot.withValue(true, function () {
|
|
1476
|
+
masking.disableWarningsSlot.withValue(true, function () {
|
|
1638
1477
|
while (keyFn) {
|
|
1639
1478
|
var specifierOrId = keyFn(tslib.__assign(tslib.__assign({}, object), storeObject), context);
|
|
1640
1479
|
if (utilities.isArray(specifierOrId)) {
|