@apollo/client 3.4.13 → 3.4.14
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.js +51 -40
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -1
- package/cache/cache.cjs.js +46 -36
- package/cache/cache.cjs.js.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.js +5 -4
- package/core/core.cjs.js.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +8 -8
- package/version.js +1 -1
package/apollo-client.cjs.js
CHANGED
|
@@ -1286,7 +1286,7 @@ var concat = ApolloLink.concat;
|
|
|
1286
1286
|
|
|
1287
1287
|
var execute = ApolloLink.execute;
|
|
1288
1288
|
|
|
1289
|
-
var version = '3.4.
|
|
1289
|
+
var version = '3.4.14';
|
|
1290
1290
|
|
|
1291
1291
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1292
1292
|
function parseAndCheckHttpResponse(operations) {
|
|
@@ -1645,6 +1645,36 @@ var MissingFieldError = (function (_super) {
|
|
|
1645
1645
|
}(Error));
|
|
1646
1646
|
|
|
1647
1647
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
1648
|
+
function defaultDataIdFromObject(_a, context) {
|
|
1649
|
+
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
1650
|
+
if (typeof __typename === "string") {
|
|
1651
|
+
if (context) {
|
|
1652
|
+
context.keyObject =
|
|
1653
|
+
id !== void 0 ? { id: id } :
|
|
1654
|
+
_id !== void 0 ? { _id: _id } :
|
|
1655
|
+
void 0;
|
|
1656
|
+
}
|
|
1657
|
+
if (id === void 0)
|
|
1658
|
+
id = _id;
|
|
1659
|
+
if (id !== void 0) {
|
|
1660
|
+
return __typename + ":" + ((typeof id === "number" ||
|
|
1661
|
+
typeof id === "string") ? id : JSON.stringify(id));
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
var defaultConfig = {
|
|
1666
|
+
dataIdFromObject: defaultDataIdFromObject,
|
|
1667
|
+
addTypename: true,
|
|
1668
|
+
resultCaching: true,
|
|
1669
|
+
canonizeResults: false,
|
|
1670
|
+
};
|
|
1671
|
+
function normalizeConfig(config) {
|
|
1672
|
+
return compact(defaultConfig, config);
|
|
1673
|
+
}
|
|
1674
|
+
function shouldCanonizeResults(config) {
|
|
1675
|
+
var value = config.canonizeResults;
|
|
1676
|
+
return value === void 0 ? defaultConfig.canonizeResults : value;
|
|
1677
|
+
}
|
|
1648
1678
|
function getTypenameFromStoreObject(store, objectOrReference) {
|
|
1649
1679
|
return isReference(objectOrReference)
|
|
1650
1680
|
? store.get(objectOrReference.__ref, "__typename")
|
|
@@ -1873,14 +1903,14 @@ var EntityStore = (function () {
|
|
|
1873
1903
|
}
|
|
1874
1904
|
return false;
|
|
1875
1905
|
};
|
|
1876
|
-
EntityStore.prototype.evict = function (options) {
|
|
1906
|
+
EntityStore.prototype.evict = function (options, limit) {
|
|
1877
1907
|
var evicted = false;
|
|
1878
1908
|
if (options.id) {
|
|
1879
1909
|
if (hasOwn.call(this.data, options.id)) {
|
|
1880
1910
|
evicted = this.delete(options.id, options.fieldName, options.args);
|
|
1881
1911
|
}
|
|
1882
|
-
if (this instanceof Layer) {
|
|
1883
|
-
evicted = this.parent.evict(options) || evicted;
|
|
1912
|
+
if (this instanceof Layer && this !== limit) {
|
|
1913
|
+
evicted = this.parent.evict(options, limit) || evicted;
|
|
1884
1914
|
}
|
|
1885
1915
|
if (options.fieldName || evicted) {
|
|
1886
1916
|
this.group.dirty(options.id, options.fieldName || "__exists");
|
|
@@ -2268,7 +2298,10 @@ var StoreReader = (function () {
|
|
|
2268
2298
|
function StoreReader(config) {
|
|
2269
2299
|
var _this = this;
|
|
2270
2300
|
this.knownResults = new (canUseWeakMap ? WeakMap : Map)();
|
|
2271
|
-
this.config =
|
|
2301
|
+
this.config = compact(config, {
|
|
2302
|
+
addTypename: config.addTypename !== false,
|
|
2303
|
+
canonizeResults: shouldCanonizeResults(config),
|
|
2304
|
+
});
|
|
2272
2305
|
this.canon = config.canon || new ObjectCanon;
|
|
2273
2306
|
this.executeSelectionSet = optimism.wrap(function (options) {
|
|
2274
2307
|
var _a;
|
|
@@ -2310,7 +2343,7 @@ var StoreReader = (function () {
|
|
|
2310
2343
|
this.canon = new ObjectCanon;
|
|
2311
2344
|
};
|
|
2312
2345
|
StoreReader.prototype.diffQueryAgainstStore = function (_a) {
|
|
2313
|
-
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 ?
|
|
2346
|
+
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;
|
|
2314
2347
|
var policies = this.config.cache.policies;
|
|
2315
2348
|
variables = tslib.__assign(tslib.__assign({}, getDefaultValues(getQueryDefinition(query))), variables);
|
|
2316
2349
|
var rootRef = makeReference(rootId);
|
|
@@ -2890,23 +2923,6 @@ function argsFromFieldSpecifier(spec) {
|
|
|
2890
2923
|
return spec.args !== void 0 ? spec.args :
|
|
2891
2924
|
spec.field ? argumentsObjectFromField(spec.field, spec.variables) : null;
|
|
2892
2925
|
}
|
|
2893
|
-
var defaultDataIdFromObject = function (_a, context) {
|
|
2894
|
-
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
2895
|
-
if (typeof __typename === "string") {
|
|
2896
|
-
if (context) {
|
|
2897
|
-
context.keyObject =
|
|
2898
|
-
id !== void 0 ? { id: id } :
|
|
2899
|
-
_id !== void 0 ? { _id: _id } :
|
|
2900
|
-
void 0;
|
|
2901
|
-
}
|
|
2902
|
-
if (id === void 0)
|
|
2903
|
-
id = _id;
|
|
2904
|
-
if (id !== void 0) {
|
|
2905
|
-
return __typename + ":" + ((typeof id === "number" ||
|
|
2906
|
-
typeof id === "string") ? id : JSON.stringify(id));
|
|
2907
|
-
}
|
|
2908
|
-
}
|
|
2909
|
-
};
|
|
2910
2926
|
var nullKeyFieldsFn = function () { return void 0; };
|
|
2911
2927
|
var simpleKeyArgsFn = function (_args, context) { return context.fieldName; };
|
|
2912
2928
|
var mergeTrueFn = function (existing, incoming, _a) {
|
|
@@ -3381,12 +3397,6 @@ function computeKeyObject(response, specifier, strict, aliasMap) {
|
|
|
3381
3397
|
return keyObj;
|
|
3382
3398
|
}
|
|
3383
3399
|
|
|
3384
|
-
var defaultConfig = {
|
|
3385
|
-
dataIdFromObject: defaultDataIdFromObject,
|
|
3386
|
-
addTypename: true,
|
|
3387
|
-
resultCaching: true,
|
|
3388
|
-
typePolicies: {},
|
|
3389
|
-
};
|
|
3390
3400
|
var InMemoryCache = (function (_super) {
|
|
3391
3401
|
tslib.__extends(InMemoryCache, _super);
|
|
3392
3402
|
function InMemoryCache(config) {
|
|
@@ -3396,7 +3406,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3396
3406
|
_this.typenameDocumentCache = new Map();
|
|
3397
3407
|
_this.makeVar = makeVar;
|
|
3398
3408
|
_this.txCount = 0;
|
|
3399
|
-
_this.config =
|
|
3409
|
+
_this.config = normalizeConfig(config);
|
|
3400
3410
|
_this.addTypename = !!_this.config.addTypename;
|
|
3401
3411
|
_this.policies = new Policies({
|
|
3402
3412
|
cache: _this,
|
|
@@ -3422,6 +3432,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3422
3432
|
cache: this,
|
|
3423
3433
|
addTypename: this.addTypename,
|
|
3424
3434
|
resultCacheMaxSize: this.config.resultCacheMaxSize,
|
|
3435
|
+
canonizeResults: shouldCanonizeResults(this.config),
|
|
3425
3436
|
canon: resetResultIdentities
|
|
3426
3437
|
? void 0
|
|
3427
3438
|
: previousReader && previousReader.canon,
|
|
@@ -3544,7 +3555,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3544
3555
|
}
|
|
3545
3556
|
try {
|
|
3546
3557
|
++this.txCount;
|
|
3547
|
-
return this.optimisticData.evict(options);
|
|
3558
|
+
return this.optimisticData.evict(options, this.data);
|
|
3548
3559
|
}
|
|
3549
3560
|
finally {
|
|
3550
3561
|
if (!--this.txCount && options.broadcast !== false) {
|
|
@@ -3553,8 +3564,11 @@ var InMemoryCache = (function (_super) {
|
|
|
3553
3564
|
}
|
|
3554
3565
|
};
|
|
3555
3566
|
InMemoryCache.prototype.reset = function () {
|
|
3567
|
+
var _this = this;
|
|
3556
3568
|
this.init();
|
|
3557
|
-
this.
|
|
3569
|
+
this.watches.forEach(function (watch) { return _this.maybeBroadcastWatch.forget(watch); });
|
|
3570
|
+
this.watches.clear();
|
|
3571
|
+
forgetCache(this);
|
|
3558
3572
|
canonicalStringify.reset();
|
|
3559
3573
|
return Promise.resolve();
|
|
3560
3574
|
};
|
|
@@ -3644,11 +3658,7 @@ var InMemoryCache = (function (_super) {
|
|
|
3644
3658
|
};
|
|
3645
3659
|
InMemoryCache.prototype.broadcastWatch = function (c, options) {
|
|
3646
3660
|
var lastDiff = c.lastDiff;
|
|
3647
|
-
var diff = this.diff(
|
|
3648
|
-
query: c.query,
|
|
3649
|
-
variables: c.variables,
|
|
3650
|
-
optimistic: c.optimistic,
|
|
3651
|
-
});
|
|
3661
|
+
var diff = this.diff(c);
|
|
3652
3662
|
if (options) {
|
|
3653
3663
|
if (c.optimistic &&
|
|
3654
3664
|
typeof options.optimistic === "string") {
|
|
@@ -4496,14 +4506,14 @@ var QueryInfo = (function () {
|
|
|
4496
4506
|
} : void 0;
|
|
4497
4507
|
};
|
|
4498
4508
|
QueryInfo.prototype.getDiffOptions = function (variables) {
|
|
4509
|
+
var _a;
|
|
4499
4510
|
if (variables === void 0) { variables = this.variables; }
|
|
4500
|
-
var oq = this.observableQuery;
|
|
4501
4511
|
return {
|
|
4502
4512
|
query: this.document,
|
|
4503
4513
|
variables: variables,
|
|
4504
4514
|
returnPartialData: true,
|
|
4505
4515
|
optimistic: true,
|
|
4506
|
-
canonizeResults:
|
|
4516
|
+
canonizeResults: (_a = this.observableQuery) === null || _a === void 0 ? void 0 : _a.options.canonizeResults,
|
|
4507
4517
|
};
|
|
4508
4518
|
};
|
|
4509
4519
|
QueryInfo.prototype.setDiff = function (diff) {
|
|
@@ -5076,7 +5086,8 @@ var QueryManager = (function () {
|
|
|
5076
5086
|
return;
|
|
5077
5087
|
}
|
|
5078
5088
|
var queryName = oq.queryName, fetchPolicy = oq.options.fetchPolicy;
|
|
5079
|
-
if (fetchPolicy === "standby" ||
|
|
5089
|
+
if (fetchPolicy === "standby" ||
|
|
5090
|
+
(include === "active" && !oq.hasObservers())) {
|
|
5080
5091
|
return;
|
|
5081
5092
|
}
|
|
5082
5093
|
if (include === "active" ||
|