@apollo/client 3.5.0-beta.16 → 3.5.0-beta.17
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/apollo-client.cjs +57 -41
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +46 -36
- package/cache/cache.cjs.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/index.d.ts +3 -3
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +2 -2
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +10 -1
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +31 -1
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +2 -8
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +10 -16
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.d.ts +1 -2
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +1 -18
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +1 -0
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +7 -4
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +8 -1
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/types.js.map +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +2 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +2 -1
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +5 -4
- package/core/core.cjs.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +8 -8
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeDeep.js +6 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/utilities.cjs +6 -1
- package/utilities/utilities.cjs.map +1 -1
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -760,7 +760,12 @@ var DeepMerger = (function () {
|
|
|
760
760
|
return source;
|
|
761
761
|
};
|
|
762
762
|
DeepMerger.prototype.shallowCopyForMerge = function (value) {
|
|
763
|
-
if (isNonNullObject(value)
|
|
763
|
+
if (isNonNullObject(value)) {
|
|
764
|
+
if (this.pastCopies.has(value)) {
|
|
765
|
+
if (!Object.isFrozen(value))
|
|
766
|
+
return value;
|
|
767
|
+
this.pastCopies.delete(value);
|
|
768
|
+
}
|
|
764
769
|
if (Array.isArray(value)) {
|
|
765
770
|
value = value.slice(0);
|
|
766
771
|
}
|
|
@@ -1286,7 +1291,7 @@ var concat = ApolloLink.concat;
|
|
|
1286
1291
|
|
|
1287
1292
|
var execute = ApolloLink.execute;
|
|
1288
1293
|
|
|
1289
|
-
var version = '3.5.0-beta.
|
|
1294
|
+
var version = '3.5.0-beta.17';
|
|
1290
1295
|
|
|
1291
1296
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1292
1297
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1669,6 +1674,36 @@ var MissingFieldError = (function () {
|
|
|
1669
1674
|
}());
|
|
1670
1675
|
|
|
1671
1676
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1677
|
+
function defaultDataIdFromObject(_a, context) {
|
|
1678
|
+
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
1679
|
+
if (typeof __typename === "string") {
|
|
1680
|
+
if (context) {
|
|
1681
|
+
context.keyObject =
|
|
1682
|
+
id !== void 0 ? { id: id } :
|
|
1683
|
+
_id !== void 0 ? { _id: _id } :
|
|
1684
|
+
void 0;
|
|
1685
|
+
}
|
|
1686
|
+
if (id === void 0)
|
|
1687
|
+
id = _id;
|
|
1688
|
+
if (id !== void 0) {
|
|
1689
|
+
return __typename + ":" + ((typeof id === "number" ||
|
|
1690
|
+
typeof id === "string") ? id : JSON.stringify(id));
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
var defaultConfig = {
|
|
1695
|
+
dataIdFromObject: defaultDataIdFromObject,
|
|
1696
|
+
addTypename: true,
|
|
1697
|
+
resultCaching: true,
|
|
1698
|
+
canonizeResults: false,
|
|
1699
|
+
};
|
|
1700
|
+
function normalizeConfig(config) {
|
|
1701
|
+
return compact(defaultConfig, config);
|
|
1702
|
+
}
|
|
1703
|
+
function shouldCanonizeResults(config) {
|
|
1704
|
+
var value = config.canonizeResults;
|
|
1705
|
+
return value === void 0 ? defaultConfig.canonizeResults : value;
|
|
1706
|
+
}
|
|
1672
1707
|
function getTypenameFromStoreObject(store, objectOrReference) {
|
|
1673
1708
|
return isReference(objectOrReference)
|
|
1674
1709
|
? store.get(objectOrReference.__ref, "__typename")
|
|
@@ -1897,14 +1932,14 @@ var EntityStore = (function () {
|
|
|
1897
1932
|
}
|
|
1898
1933
|
return false;
|
|
1899
1934
|
};
|
|
1900
|
-
EntityStore.prototype.evict = function (options) {
|
|
1935
|
+
EntityStore.prototype.evict = function (options, limit) {
|
|
1901
1936
|
var evicted = false;
|
|
1902
1937
|
if (options.id) {
|
|
1903
1938
|
if (hasOwn.call(this.data, options.id)) {
|
|
1904
1939
|
evicted = this.delete(options.id, options.fieldName, options.args);
|
|
1905
1940
|
}
|
|
1906
|
-
if (this instanceof Layer) {
|
|
1907
|
-
evicted = this.parent.evict(options) || evicted;
|
|
1941
|
+
if (this instanceof Layer && this !== limit) {
|
|
1942
|
+
evicted = this.parent.evict(options, limit) || evicted;
|
|
1908
1943
|
}
|
|
1909
1944
|
if (options.fieldName || evicted) {
|
|
1910
1945
|
this.group.dirty(options.id, options.fieldName || "__exists");
|
|
@@ -2289,7 +2324,10 @@ var StoreReader = (function () {
|
|
|
2289
2324
|
function StoreReader(config) {
|
|
2290
2325
|
var _this = this;
|
|
2291
2326
|
this.knownResults = new (canUseWeakMap ? WeakMap : Map)();
|
|
2292
|
-
this.config =
|
|
2327
|
+
this.config = compact(config, {
|
|
2328
|
+
addTypename: config.addTypename !== false,
|
|
2329
|
+
canonizeResults: shouldCanonizeResults(config),
|
|
2330
|
+
});
|
|
2293
2331
|
this.canon = config.canon || new ObjectCanon;
|
|
2294
2332
|
this.executeSelectionSet = optimism.wrap(function (options) {
|
|
2295
2333
|
var _a;
|
|
@@ -2331,7 +2369,7 @@ var StoreReader = (function () {
|
|
|
2331
2369
|
this.canon = new ObjectCanon;
|
|
2332
2370
|
};
|
|
2333
2371
|
StoreReader.prototype.diffQueryAgainstStore = function (_a) {
|
|
2334
|
-
var store = _a.store, query = _a.query, _b = _a.rootId, rootId = _b === void 0 ? 'ROOT_QUERY' : _b, variables = _a.variables, _c = _a.returnPartialData, returnPartialData = _c === void 0 ? true : _c, _d = _a.canonizeResults, canonizeResults = _d === void 0 ?
|
|
2372
|
+
var store = _a.store, query = _a.query, _b = _a.rootId, rootId = _b === void 0 ? 'ROOT_QUERY' : _b, variables = _a.variables, _c = _a.returnPartialData, returnPartialData = _c === void 0 ? true : _c, _d = _a.canonizeResults, canonizeResults = _d === void 0 ? this.config.canonizeResults : _d;
|
|
2335
2373
|
var policies = this.config.cache.policies;
|
|
2336
2374
|
variables = tslib.__assign(tslib.__assign({}, getDefaultValues(getQueryDefinition(query))), variables);
|
|
2337
2375
|
var rootRef = makeReference(rootId);
|
|
@@ -2928,23 +2966,6 @@ function argsFromFieldSpecifier(spec) {
|
|
|
2928
2966
|
return spec.args !== void 0 ? spec.args :
|
|
2929
2967
|
spec.field ? argumentsObjectFromField(spec.field, spec.variables) : null;
|
|
2930
2968
|
}
|
|
2931
|
-
var defaultDataIdFromObject = function (_a, context) {
|
|
2932
|
-
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
2933
|
-
if (typeof __typename === "string") {
|
|
2934
|
-
if (context) {
|
|
2935
|
-
context.keyObject =
|
|
2936
|
-
id !== void 0 ? { id: id } :
|
|
2937
|
-
_id !== void 0 ? { _id: _id } :
|
|
2938
|
-
void 0;
|
|
2939
|
-
}
|
|
2940
|
-
if (id === void 0)
|
|
2941
|
-
id = _id;
|
|
2942
|
-
if (id !== void 0) {
|
|
2943
|
-
return __typename + ":" + ((typeof id === "number" ||
|
|
2944
|
-
typeof id === "string") ? id : JSON.stringify(id));
|
|
2945
|
-
}
|
|
2946
|
-
}
|
|
2947
|
-
};
|
|
2948
2969
|
var nullKeyFieldsFn = function () { return void 0; };
|
|
2949
2970
|
var simpleKeyArgsFn = function (_args, context) { return context.fieldName; };
|
|
2950
2971
|
var mergeTrueFn = function (existing, incoming, _a) {
|
|
@@ -3462,12 +3483,6 @@ function computeKeyArgsObject(specifier, field, source, variables) {
|
|
|
3462
3483
|
return keyObj;
|
|
3463
3484
|
}
|
|
3464
3485
|
|
|
3465
|
-
var defaultConfig = {
|
|
3466
|
-
dataIdFromObject: defaultDataIdFromObject,
|
|
3467
|
-
addTypename: true,
|
|
3468
|
-
resultCaching: true,
|
|
3469
|
-
typePolicies: {},
|
|
3470
|
-
};
|
|
3471
3486
|
var InMemoryCache = (function (_super) {
|
|
3472
3487
|
tslib.__extends(InMemoryCache, _super);
|
|
3473
3488
|
function InMemoryCache(config) {
|
|
@@ -3477,7 +3492,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3477
3492
|
_this.typenameDocumentCache = new Map();
|
|
3478
3493
|
_this.makeVar = makeVar;
|
|
3479
3494
|
_this.txCount = 0;
|
|
3480
|
-
_this.config =
|
|
3495
|
+
_this.config = normalizeConfig(config);
|
|
3481
3496
|
_this.addTypename = !!_this.config.addTypename;
|
|
3482
3497
|
_this.policies = new Policies({
|
|
3483
3498
|
cache: _this,
|
|
@@ -3503,6 +3518,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3503
3518
|
cache: this,
|
|
3504
3519
|
addTypename: this.addTypename,
|
|
3505
3520
|
resultCacheMaxSize: this.config.resultCacheMaxSize,
|
|
3521
|
+
canonizeResults: shouldCanonizeResults(this.config),
|
|
3506
3522
|
canon: resetResultIdentities
|
|
3507
3523
|
? void 0
|
|
3508
3524
|
: previousReader && previousReader.canon,
|
|
@@ -3631,7 +3647,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3631
3647
|
}
|
|
3632
3648
|
try {
|
|
3633
3649
|
++this.txCount;
|
|
3634
|
-
return this.optimisticData.evict(options);
|
|
3650
|
+
return this.optimisticData.evict(options, this.data);
|
|
3635
3651
|
}
|
|
3636
3652
|
finally {
|
|
3637
3653
|
if (!--this.txCount && options.broadcast !== false) {
|
|
@@ -3640,8 +3656,11 @@ var InMemoryCache = (function (_super) {
|
|
|
3640
3656
|
}
|
|
3641
3657
|
};
|
|
3642
3658
|
InMemoryCache.prototype.reset = function () {
|
|
3659
|
+
var _this = this;
|
|
3643
3660
|
this.init();
|
|
3644
|
-
this.
|
|
3661
|
+
this.watches.forEach(function (watch) { return _this.maybeBroadcastWatch.forget(watch); });
|
|
3662
|
+
this.watches.clear();
|
|
3663
|
+
forgetCache(this);
|
|
3645
3664
|
canonicalStringify.reset();
|
|
3646
3665
|
return Promise.resolve();
|
|
3647
3666
|
};
|
|
@@ -3733,11 +3752,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3733
3752
|
};
|
|
3734
3753
|
InMemoryCache.prototype.broadcastWatch = function (c, options) {
|
|
3735
3754
|
var lastDiff = c.lastDiff;
|
|
3736
|
-
var diff = this.diff(
|
|
3737
|
-
query: c.query,
|
|
3738
|
-
variables: c.variables,
|
|
3739
|
-
optimistic: c.optimistic,
|
|
3740
|
-
});
|
|
3755
|
+
var diff = this.diff(c);
|
|
3741
3756
|
if (options) {
|
|
3742
3757
|
if (c.optimistic &&
|
|
3743
3758
|
typeof options.optimistic === "string") {
|
|
@@ -4589,14 +4604,14 @@ var QueryInfo = (function () {
|
|
|
4589
4604
|
} : void 0;
|
|
4590
4605
|
};
|
|
4591
4606
|
QueryInfo.prototype.getDiffOptions = function (variables) {
|
|
4607
|
+
var _a;
|
|
4592
4608
|
if (variables === void 0) { variables = this.variables; }
|
|
4593
|
-
var oq = this.observableQuery;
|
|
4594
4609
|
return {
|
|
4595
4610
|
query: this.document,
|
|
4596
4611
|
variables: variables,
|
|
4597
4612
|
returnPartialData: true,
|
|
4598
4613
|
optimistic: true,
|
|
4599
|
-
canonizeResults:
|
|
4614
|
+
canonizeResults: (_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.options.canonizeResults,
|
|
4600
4615
|
};
|
|
4601
4616
|
};
|
|
4602
4617
|
QueryInfo.prototype.setDiff = function (diff) {
|
|
@@ -5169,7 +5184,8 @@ var QueryManager = (function () {
|
|
|
5169
5184
|
return;
|
|
5170
5185
|
}
|
|
5171
5186
|
var queryName = oq.queryName, fetchPolicy = oq.options.fetchPolicy;
|
|
5172
|
-
if (fetchPolicy === "standby" ||
|
|
5187
|
+
if (fetchPolicy === "standby" ||
|
|
5188
|
+
(include === "active" && !oq.hasObservers())) {
|
|
5173
5189
|
return;
|
|
5174
5190
|
}
|
|
5175
5191
|
if (include === "active" ||
|