@apollo/client 3.5.7 → 3.5.10
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 +58 -59
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +21 -20
- package/cache/cache.cjs.map +1 -1
- package/cache/inmemory/helpers.d.ts +1 -0
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +3 -2
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/key-extractor.js +5 -5
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +2 -1
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +6 -6
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +3 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.js +7 -7
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +6 -3
- package/core/ObservableQuery.js.map +1 -1
- package/core/core.cjs +7 -4
- package/core/core.cjs.map +1 -1
- package/invariantErrorCodes.js +3 -3
- package/link/subscriptions/index.d.ts +9 -0
- package/link/subscriptions/index.d.ts.map +1 -0
- package/link/subscriptions/index.js +39 -0
- package/link/subscriptions/index.js.map +1 -0
- package/link/subscriptions/package.json +8 -0
- package/link/subscriptions/subscriptions.cjs +45 -0
- package/link/subscriptions/subscriptions.cjs.map +1 -0
- package/package.json +16 -11
- package/react/hooks/hooks.cjs +30 -35
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +20 -27
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +10 -8
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/types/types.d.ts +1 -1
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/utilities/globals/global.d.ts +2 -8
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/version.js +1 -1
package/cache/cache.cjs
CHANGED
|
@@ -147,7 +147,7 @@ function fieldNameFromStoreName(storeFieldName) {
|
|
|
147
147
|
}
|
|
148
148
|
function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
149
149
|
if (utilities.isNonNullObject(result)) {
|
|
150
|
-
return
|
|
150
|
+
return isArray(result)
|
|
151
151
|
? result.every(function (item) { return selectionSetMatchesResult(selectionSet, item, variables); })
|
|
152
152
|
: selectionSet.selections.every(function (field) {
|
|
153
153
|
if (utilities.isField(field) && utilities.shouldInclude(field, variables)) {
|
|
@@ -164,11 +164,12 @@ function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
|
164
164
|
function storeValueIsStoreObject(value) {
|
|
165
165
|
return utilities.isNonNullObject(value) &&
|
|
166
166
|
!utilities.isReference(value) &&
|
|
167
|
-
!
|
|
167
|
+
!isArray(value);
|
|
168
168
|
}
|
|
169
169
|
function makeProcessedFieldsMerger() {
|
|
170
170
|
return new utilities.DeepMerger;
|
|
171
171
|
}
|
|
172
|
+
var isArray = function (a) { return Array.isArray(a); };
|
|
172
173
|
|
|
173
174
|
var DELETE = Object.create(null);
|
|
174
175
|
var delModifier = function () { return DELETE; };
|
|
@@ -631,7 +632,7 @@ function supportsResultCaching(store) {
|
|
|
631
632
|
|
|
632
633
|
function shallowCopy(value) {
|
|
633
634
|
if (utilities.isNonNullObject(value)) {
|
|
634
|
-
return
|
|
635
|
+
return isArray(value)
|
|
635
636
|
? value.slice(0)
|
|
636
637
|
: tslib.__assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
637
638
|
}
|
|
@@ -894,7 +895,7 @@ var StoreReader = (function () {
|
|
|
894
895
|
_a));
|
|
895
896
|
}
|
|
896
897
|
}
|
|
897
|
-
else if (
|
|
898
|
+
else if (isArray(fieldValue)) {
|
|
898
899
|
fieldValue = handleMissing(_this.executeSubSelectedArray({
|
|
899
900
|
field: selection,
|
|
900
901
|
array: fieldValue,
|
|
@@ -953,7 +954,7 @@ var StoreReader = (function () {
|
|
|
953
954
|
if (item === null) {
|
|
954
955
|
return null;
|
|
955
956
|
}
|
|
956
|
-
if (
|
|
957
|
+
if (isArray(item)) {
|
|
957
958
|
return handleMissing(_this.executeSubSelectedArray({
|
|
958
959
|
field: field,
|
|
959
960
|
array: item,
|
|
@@ -1147,13 +1148,13 @@ function getSpecifierPaths(spec) {
|
|
|
1147
1148
|
var paths_1 = info.paths = [];
|
|
1148
1149
|
var currentPath_1 = [];
|
|
1149
1150
|
spec.forEach(function (s, i) {
|
|
1150
|
-
if (
|
|
1151
|
+
if (isArray(s)) {
|
|
1151
1152
|
getSpecifierPaths(s).forEach(function (p) { return paths_1.push(currentPath_1.concat(p)); });
|
|
1152
1153
|
currentPath_1.length = 0;
|
|
1153
1154
|
}
|
|
1154
1155
|
else {
|
|
1155
1156
|
currentPath_1.push(s);
|
|
1156
|
-
if (!
|
|
1157
|
+
if (!isArray(spec[i + 1])) {
|
|
1157
1158
|
paths_1.push(currentPath_1.slice(0));
|
|
1158
1159
|
currentPath_1.length = 0;
|
|
1159
1160
|
}
|
|
@@ -1168,14 +1169,14 @@ function extractKey(object, key) {
|
|
|
1168
1169
|
function extractKeyPath(object, path, extract) {
|
|
1169
1170
|
extract = extract || extractKey;
|
|
1170
1171
|
return normalize(path.reduce(function reducer(obj, key) {
|
|
1171
|
-
return
|
|
1172
|
+
return isArray(obj)
|
|
1172
1173
|
? obj.map(function (child) { return reducer(child, key); })
|
|
1173
1174
|
: obj && extract(obj, key);
|
|
1174
1175
|
}, object));
|
|
1175
1176
|
}
|
|
1176
1177
|
function normalize(value) {
|
|
1177
1178
|
if (utilities.isNonNullObject(value)) {
|
|
1178
|
-
if (
|
|
1179
|
+
if (isArray(value)) {
|
|
1179
1180
|
return value.map(normalize);
|
|
1180
1181
|
}
|
|
1181
1182
|
return collectSpecifierPaths(Object.keys(value).sort(), function (path) { return extractKeyPath(value, path); });
|
|
@@ -1238,7 +1239,7 @@ var Policies = (function () {
|
|
|
1238
1239
|
var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
|
|
1239
1240
|
while (keyFn) {
|
|
1240
1241
|
var specifierOrId = keyFn(object, context);
|
|
1241
|
-
if (
|
|
1242
|
+
if (isArray(specifierOrId)) {
|
|
1242
1243
|
keyFn = keyFieldsFnFromSpecifier(specifierOrId);
|
|
1243
1244
|
}
|
|
1244
1245
|
else {
|
|
@@ -1281,7 +1282,7 @@ var Policies = (function () {
|
|
|
1281
1282
|
setMerge(existing, incoming.merge);
|
|
1282
1283
|
existing.keyFn =
|
|
1283
1284
|
keyFields === false ? nullKeyFieldsFn :
|
|
1284
|
-
|
|
1285
|
+
isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) :
|
|
1285
1286
|
typeof keyFields === "function" ? keyFields :
|
|
1286
1287
|
existing.keyFn;
|
|
1287
1288
|
if (fields) {
|
|
@@ -1295,7 +1296,7 @@ var Policies = (function () {
|
|
|
1295
1296
|
var keyArgs = incoming.keyArgs, read = incoming.read, merge = incoming.merge;
|
|
1296
1297
|
existing.keyFn =
|
|
1297
1298
|
keyArgs === false ? simpleKeyArgsFn :
|
|
1298
|
-
|
|
1299
|
+
isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) :
|
|
1299
1300
|
typeof keyArgs === "function" ? keyArgs :
|
|
1300
1301
|
existing.keyFn;
|
|
1301
1302
|
if (typeof read === "function") {
|
|
@@ -1440,7 +1441,7 @@ var Policies = (function () {
|
|
|
1440
1441
|
var args = argsFromFieldSpecifier(fieldSpec);
|
|
1441
1442
|
while (keyFn) {
|
|
1442
1443
|
var specifierOrString = keyFn(args, context);
|
|
1443
|
-
if (
|
|
1444
|
+
if (isArray(specifierOrString)) {
|
|
1444
1445
|
keyFn = keyArgsFnFromSpecifier(specifierOrString);
|
|
1445
1446
|
}
|
|
1446
1447
|
else {
|
|
@@ -1561,7 +1562,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
|
|
|
1561
1562
|
}
|
|
1562
1563
|
function makeMergeObjectsFunction(store) {
|
|
1563
1564
|
return function mergeObjects(existing, incoming) {
|
|
1564
|
-
if (
|
|
1565
|
+
if (isArray(existing) || isArray(incoming)) {
|
|
1565
1566
|
throw __DEV__ ? new globals.InvariantError("Cannot automatically merge arrays") : new globals.InvariantError(4);
|
|
1566
1567
|
}
|
|
1567
1568
|
if (utilities.isNonNullObject(existing) &&
|
|
@@ -1790,7 +1791,7 @@ var StoreWriter = (function () {
|
|
|
1790
1791
|
if (!field.selectionSet || value === null) {
|
|
1791
1792
|
return __DEV__ ? utilities.cloneDeep(value) : value;
|
|
1792
1793
|
}
|
|
1793
|
-
if (
|
|
1794
|
+
if (isArray(value)) {
|
|
1794
1795
|
return value.map(function (item, i) {
|
|
1795
1796
|
var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
|
|
1796
1797
|
maybeRecycleChildMergeTree(mergeTree, i);
|
|
@@ -1855,7 +1856,7 @@ var StoreWriter = (function () {
|
|
|
1855
1856
|
var _a;
|
|
1856
1857
|
var _this = this;
|
|
1857
1858
|
if (mergeTree.map.size && !utilities.isReference(incoming)) {
|
|
1858
|
-
var e_1 = (!
|
|
1859
|
+
var e_1 = (!isArray(incoming) &&
|
|
1859
1860
|
(utilities.isReference(existing) || storeValueIsStoreObject(existing))) ? existing : void 0;
|
|
1860
1861
|
var i_1 = incoming;
|
|
1861
1862
|
if (e_1 && !getStorageArgs) {
|
|
@@ -1863,7 +1864,7 @@ var StoreWriter = (function () {
|
|
|
1863
1864
|
}
|
|
1864
1865
|
var changedFields_1;
|
|
1865
1866
|
var getValue_1 = function (from, name) {
|
|
1866
|
-
return
|
|
1867
|
+
return isArray(from)
|
|
1867
1868
|
? (typeof name === "number" ? from[name] : void 0)
|
|
1868
1869
|
: context.store.getFieldValue(from, String(name));
|
|
1869
1870
|
};
|
|
@@ -1885,7 +1886,7 @@ var StoreWriter = (function () {
|
|
|
1885
1886
|
}
|
|
1886
1887
|
});
|
|
1887
1888
|
if (changedFields_1) {
|
|
1888
|
-
incoming = (
|
|
1889
|
+
incoming = (isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
|
|
1889
1890
|
changedFields_1.forEach(function (value, name) {
|
|
1890
1891
|
incoming[name] = value;
|
|
1891
1892
|
});
|
|
@@ -1966,8 +1967,8 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
1966
1967
|
return;
|
|
1967
1968
|
warnings.add(typeDotName);
|
|
1968
1969
|
var childTypenames = [];
|
|
1969
|
-
if (!
|
|
1970
|
-
!
|
|
1970
|
+
if (!isArray(existing) &&
|
|
1971
|
+
!isArray(incoming)) {
|
|
1971
1972
|
[existing, incoming].forEach(function (child) {
|
|
1972
1973
|
var typename = store.getFieldValue(child, "__typename");
|
|
1973
1974
|
if (typeof typename === "string" &&
|