@apollo/client 3.4.12 → 3.4.16
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/README.md +8 -6
- package/apollo-client.cjs.js +89 -62
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -1
- package/cache/cache.cjs.js +52 -37
- package/cache/cache.cjs.js.map +1 -1
- package/cache/core/cache.d.ts +1 -1
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +3 -0
- package/cache/core/types/Cache.d.ts.map +1 -1
- package/cache/core/types/Cache.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 +3 -9
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +16 -17
- 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/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +6 -2
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.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 +2 -3
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +7 -9
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs.js +16 -14
- package/core/core.cjs.js.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/package.json +9 -9
- package/react/hoc/hoc.cjs.js +8 -5
- package/react/hoc/hoc.cjs.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js +8 -5
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/parser/index.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +14 -3
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/globals/{graphql.d.ts → fix-graphql.d.ts} +1 -1
- package/utilities/globals/fix-graphql.d.ts.map +1 -0
- package/utilities/globals/fix-graphql.js +6 -0
- package/utilities/globals/fix-graphql.js.map +1 -0
- package/utilities/globals/globals.cjs.js +1 -2
- package/utilities/globals/globals.cjs.js.map +1 -1
- package/utilities/globals/index.js +1 -1
- package/utilities/globals/index.js.map +1 -1
- package/utilities/observables/subclassing.js +1 -1
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/testing/mocking/mockFetch.js.map +1 -1
- package/utilities/utilities.cjs.js +21 -11
- package/utilities/utilities.cjs.js.map +1 -1
- package/version.js +1 -1
- package/utilities/globals/graphql.d.ts.map +0 -1
- package/utilities/globals/graphql.js +0 -7
- package/utilities/globals/graphql.js.map +0 -1
package/cache/cache.cjs.js
CHANGED
|
@@ -82,6 +82,36 @@ var MissingFieldError = (function (_super) {
|
|
|
82
82
|
}(Error));
|
|
83
83
|
|
|
84
84
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
85
|
+
function defaultDataIdFromObject(_a, context) {
|
|
86
|
+
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
87
|
+
if (typeof __typename === "string") {
|
|
88
|
+
if (context) {
|
|
89
|
+
context.keyObject =
|
|
90
|
+
id !== void 0 ? { id: id } :
|
|
91
|
+
_id !== void 0 ? { _id: _id } :
|
|
92
|
+
void 0;
|
|
93
|
+
}
|
|
94
|
+
if (id === void 0)
|
|
95
|
+
id = _id;
|
|
96
|
+
if (id !== void 0) {
|
|
97
|
+
return __typename + ":" + ((typeof id === "number" ||
|
|
98
|
+
typeof id === "string") ? id : JSON.stringify(id));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var defaultConfig = {
|
|
103
|
+
dataIdFromObject: defaultDataIdFromObject,
|
|
104
|
+
addTypename: true,
|
|
105
|
+
resultCaching: true,
|
|
106
|
+
canonizeResults: false,
|
|
107
|
+
};
|
|
108
|
+
function normalizeConfig(config) {
|
|
109
|
+
return utilities.compact(defaultConfig, config);
|
|
110
|
+
}
|
|
111
|
+
function shouldCanonizeResults(config) {
|
|
112
|
+
var value = config.canonizeResults;
|
|
113
|
+
return value === void 0 ? defaultConfig.canonizeResults : value;
|
|
114
|
+
}
|
|
85
115
|
function getTypenameFromStoreObject(store, objectOrReference) {
|
|
86
116
|
return utilities.isReference(objectOrReference)
|
|
87
117
|
? store.get(objectOrReference.__ref, "__typename")
|
|
@@ -310,14 +340,14 @@ exports.EntityStore = (function () {
|
|
|
310
340
|
}
|
|
311
341
|
return false;
|
|
312
342
|
};
|
|
313
|
-
EntityStore.prototype.evict = function (options) {
|
|
343
|
+
EntityStore.prototype.evict = function (options, limit) {
|
|
314
344
|
var evicted = false;
|
|
315
345
|
if (options.id) {
|
|
316
346
|
if (hasOwn.call(this.data, options.id)) {
|
|
317
347
|
evicted = this.delete(options.id, options.fieldName, options.args);
|
|
318
348
|
}
|
|
319
|
-
if (this instanceof Layer) {
|
|
320
|
-
evicted = this.parent.evict(options) || evicted;
|
|
349
|
+
if (this instanceof Layer && this !== limit) {
|
|
350
|
+
evicted = this.parent.evict(options, limit) || evicted;
|
|
321
351
|
}
|
|
322
352
|
if (options.fieldName || evicted) {
|
|
323
353
|
this.group.dirty(options.id, options.fieldName || "__exists");
|
|
@@ -705,7 +735,10 @@ var StoreReader = (function () {
|
|
|
705
735
|
function StoreReader(config) {
|
|
706
736
|
var _this = this;
|
|
707
737
|
this.knownResults = new (utilities.canUseWeakMap ? WeakMap : Map)();
|
|
708
|
-
this.config =
|
|
738
|
+
this.config = utilities.compact(config, {
|
|
739
|
+
addTypename: config.addTypename !== false,
|
|
740
|
+
canonizeResults: shouldCanonizeResults(config),
|
|
741
|
+
});
|
|
709
742
|
this.canon = config.canon || new ObjectCanon;
|
|
710
743
|
this.executeSelectionSet = optimism.wrap(function (options) {
|
|
711
744
|
var _a;
|
|
@@ -747,7 +780,7 @@ var StoreReader = (function () {
|
|
|
747
780
|
this.canon = new ObjectCanon;
|
|
748
781
|
};
|
|
749
782
|
StoreReader.prototype.diffQueryAgainstStore = function (_a) {
|
|
750
|
-
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 ?
|
|
783
|
+
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;
|
|
751
784
|
var policies = this.config.cache.policies;
|
|
752
785
|
variables = tslib.__assign(tslib.__assign({}, utilities.getDefaultValues(utilities.getQueryDefinition(query))), variables);
|
|
753
786
|
var rootRef = utilities.makeReference(rootId);
|
|
@@ -1327,23 +1360,6 @@ function argsFromFieldSpecifier(spec) {
|
|
|
1327
1360
|
return spec.args !== void 0 ? spec.args :
|
|
1328
1361
|
spec.field ? utilities.argumentsObjectFromField(spec.field, spec.variables) : null;
|
|
1329
1362
|
}
|
|
1330
|
-
var defaultDataIdFromObject = function (_a, context) {
|
|
1331
|
-
var __typename = _a.__typename, id = _a.id, _id = _a._id;
|
|
1332
|
-
if (typeof __typename === "string") {
|
|
1333
|
-
if (context) {
|
|
1334
|
-
context.keyObject =
|
|
1335
|
-
id !== void 0 ? { id: id } :
|
|
1336
|
-
_id !== void 0 ? { _id: _id } :
|
|
1337
|
-
void 0;
|
|
1338
|
-
}
|
|
1339
|
-
if (id === void 0)
|
|
1340
|
-
id = _id;
|
|
1341
|
-
if (id !== void 0) {
|
|
1342
|
-
return __typename + ":" + ((typeof id === "number" ||
|
|
1343
|
-
typeof id === "string") ? id : JSON.stringify(id));
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
};
|
|
1347
1363
|
var nullKeyFieldsFn = function () { return void 0; };
|
|
1348
1364
|
var simpleKeyArgsFn = function (_args, context) { return context.fieldName; };
|
|
1349
1365
|
var mergeTrueFn = function (existing, incoming, _a) {
|
|
@@ -1818,12 +1834,6 @@ function computeKeyObject(response, specifier, strict, aliasMap) {
|
|
|
1818
1834
|
return keyObj;
|
|
1819
1835
|
}
|
|
1820
1836
|
|
|
1821
|
-
var defaultConfig = {
|
|
1822
|
-
dataIdFromObject: defaultDataIdFromObject,
|
|
1823
|
-
addTypename: true,
|
|
1824
|
-
resultCaching: true,
|
|
1825
|
-
typePolicies: {},
|
|
1826
|
-
};
|
|
1827
1837
|
var InMemoryCache = (function (_super) {
|
|
1828
1838
|
tslib.__extends(InMemoryCache, _super);
|
|
1829
1839
|
function InMemoryCache(config) {
|
|
@@ -1833,7 +1843,7 @@ var InMemoryCache = (function (_super) {
|
|
|
1833
1843
|
_this.typenameDocumentCache = new Map();
|
|
1834
1844
|
_this.makeVar = makeVar;
|
|
1835
1845
|
_this.txCount = 0;
|
|
1836
|
-
_this.config =
|
|
1846
|
+
_this.config = normalizeConfig(config);
|
|
1837
1847
|
_this.addTypename = !!_this.config.addTypename;
|
|
1838
1848
|
_this.policies = new Policies({
|
|
1839
1849
|
cache: _this,
|
|
@@ -1859,6 +1869,7 @@ var InMemoryCache = (function (_super) {
|
|
|
1859
1869
|
cache: this,
|
|
1860
1870
|
addTypename: this.addTypename,
|
|
1861
1871
|
resultCacheMaxSize: this.config.resultCacheMaxSize,
|
|
1872
|
+
canonizeResults: shouldCanonizeResults(this.config),
|
|
1862
1873
|
canon: resetResultIdentities
|
|
1863
1874
|
? void 0
|
|
1864
1875
|
: previousReader && previousReader.canon,
|
|
@@ -1981,7 +1992,7 @@ var InMemoryCache = (function (_super) {
|
|
|
1981
1992
|
}
|
|
1982
1993
|
try {
|
|
1983
1994
|
++this.txCount;
|
|
1984
|
-
return this.optimisticData.evict(options);
|
|
1995
|
+
return this.optimisticData.evict(options, this.data);
|
|
1985
1996
|
}
|
|
1986
1997
|
finally {
|
|
1987
1998
|
if (!--this.txCount && options.broadcast !== false) {
|
|
@@ -1989,10 +2000,18 @@ var InMemoryCache = (function (_super) {
|
|
|
1989
2000
|
}
|
|
1990
2001
|
}
|
|
1991
2002
|
};
|
|
1992
|
-
InMemoryCache.prototype.reset = function () {
|
|
2003
|
+
InMemoryCache.prototype.reset = function (options) {
|
|
2004
|
+
var _this = this;
|
|
1993
2005
|
this.init();
|
|
1994
|
-
this.broadcastWatches();
|
|
1995
2006
|
canonicalStringify.reset();
|
|
2007
|
+
if (options && options.discardWatches) {
|
|
2008
|
+
this.watches.forEach(function (watch) { return _this.maybeBroadcastWatch.forget(watch); });
|
|
2009
|
+
this.watches.clear();
|
|
2010
|
+
forgetCache(this);
|
|
2011
|
+
}
|
|
2012
|
+
else {
|
|
2013
|
+
this.broadcastWatches();
|
|
2014
|
+
}
|
|
1996
2015
|
return Promise.resolve();
|
|
1997
2016
|
};
|
|
1998
2017
|
InMemoryCache.prototype.removeOptimistic = function (idToRemove) {
|
|
@@ -2081,11 +2100,7 @@ var InMemoryCache = (function (_super) {
|
|
|
2081
2100
|
};
|
|
2082
2101
|
InMemoryCache.prototype.broadcastWatch = function (c, options) {
|
|
2083
2102
|
var lastDiff = c.lastDiff;
|
|
2084
|
-
var diff = this.diff(
|
|
2085
|
-
query: c.query,
|
|
2086
|
-
variables: c.variables,
|
|
2087
|
-
optimistic: c.optimistic,
|
|
2088
|
-
});
|
|
2103
|
+
var diff = this.diff(c);
|
|
2089
2104
|
if (options) {
|
|
2090
2105
|
if (c.optimistic &&
|
|
2091
2106
|
typeof options.optimistic === "string") {
|