@apollo/client 3.2.0-beta.9 → 3.2.2
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/LICENSE +1 -1
- package/apollo-client.cjs.js +161 -102
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -1
- package/cache/cache.cjs.js +117 -64
- package/cache/cache.cjs.js.map +1 -1
- package/cache/core/types/common.d.ts +3 -0
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +5 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +32 -19
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +3 -1
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +19 -3
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +3 -2
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.d.ts +6 -5
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +57 -26
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +1 -2
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +5 -14
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +2 -1
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +4 -3
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +2 -2
- package/core/LocalState.js +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +9 -10
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +2 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +11 -7
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +17 -14
- package/core/QueryManager.js.map +1 -1
- package/core/Reobserver.js +1 -1
- package/core/core.cjs.js +39 -33
- package/core/core.cjs.js.map +1 -1
- package/core/types.d.ts +1 -1
- package/core/types.d.ts.map +1 -1
- package/core/watchQueryOptions.d.ts +1 -0
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/invariantErrorCodes.js +32 -28
- package/link/core/ApolloLink.js +1 -1
- package/link/core/core.cjs.js +1 -1
- package/link/core/core.cjs.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/http.cjs.js +2 -2
- package/link/http/http.cjs.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts +30 -0
- package/link/persisted-queries/index.d.ts.map +1 -0
- package/link/persisted-queries/index.js +154 -0
- package/link/persisted-queries/index.js.map +1 -0
- package/link/persisted-queries/package.json +6 -0
- package/link/persisted-queries/persisted-queries.cjs.js +155 -0
- package/link/persisted-queries/persisted-queries.cjs.js.map +1 -0
- package/package.json +15 -10
- package/react/data/QueryData.js +2 -2
- package/react/data/QueryData.js.map +1 -1
- package/react/data/data.cjs.js +2 -2
- package/react/data/data.cjs.js.map +1 -1
- package/utilities/policies/pagination.d.ts +21 -12
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +49 -37
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/utilities.cjs.js +48 -37
- package/utilities/utilities.cjs.js.map +1 -1
package/cache/cache.cjs.js
CHANGED
|
@@ -90,11 +90,27 @@ function getTypenameFromStoreObject(store, objectOrReference) {
|
|
|
90
90
|
? store.get(objectOrReference.__ref, "__typename")
|
|
91
91
|
: objectOrReference && objectOrReference.__typename;
|
|
92
92
|
}
|
|
93
|
-
var
|
|
93
|
+
var TypeOrFieldNameRegExp = /^[_a-z][_0-9a-z]*/i;
|
|
94
94
|
function fieldNameFromStoreName(storeFieldName) {
|
|
95
|
-
var match = storeFieldName.match(
|
|
95
|
+
var match = storeFieldName.match(TypeOrFieldNameRegExp);
|
|
96
96
|
return match ? match[0] : storeFieldName;
|
|
97
97
|
}
|
|
98
|
+
function selectionSetMatchesResult(selectionSet, result, variables) {
|
|
99
|
+
if (result && typeof result === "object") {
|
|
100
|
+
return Array.isArray(result)
|
|
101
|
+
? result.every(function (item) { return selectionSetMatchesResult(selectionSet, item, variables); })
|
|
102
|
+
: selectionSet.selections.every(function (field) {
|
|
103
|
+
if (utilities.isField(field) && utilities.shouldInclude(field, variables)) {
|
|
104
|
+
var key = utilities.resultKeyNameFromField(field);
|
|
105
|
+
return hasOwn.call(result, key) &&
|
|
106
|
+
(!field.selectionSet ||
|
|
107
|
+
selectionSetMatchesResult(field.selectionSet, result[key], variables));
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
98
114
|
function storeValueIsStoreObject(value) {
|
|
99
115
|
return value !== null &&
|
|
100
116
|
typeof value === "object" &&
|
|
@@ -126,6 +142,7 @@ var reconcileProcessedFields = function (existingObject, incomingObject, propert
|
|
|
126
142
|
|
|
127
143
|
var DELETE = Object.create(null);
|
|
128
144
|
var delModifier = function () { return DELETE; };
|
|
145
|
+
var INVALIDATE = Object.create(null);
|
|
129
146
|
var EntityStore = (function () {
|
|
130
147
|
function EntityStore(policies, group) {
|
|
131
148
|
var _this = this;
|
|
@@ -217,10 +234,17 @@ var EntityStore = (function () {
|
|
|
217
234
|
var changedFields_1 = Object.create(null);
|
|
218
235
|
var needToMerge_1 = false;
|
|
219
236
|
var allDeleted_1 = true;
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
237
|
+
var sharedDetails_1 = {
|
|
238
|
+
DELETE: DELETE,
|
|
239
|
+
INVALIDATE: INVALIDATE,
|
|
240
|
+
isReference: utilities.isReference,
|
|
241
|
+
toReference: this.toReference,
|
|
242
|
+
canRead: this.canRead,
|
|
243
|
+
readField: function (fieldNameOrOptions, from) { return _this.policies.readField(typeof fieldNameOrOptions === "string" ? {
|
|
244
|
+
fieldName: fieldNameOrOptions,
|
|
245
|
+
from: from || utilities.makeReference(dataId),
|
|
246
|
+
} : fieldNameOrOptions, { store: _this }); },
|
|
247
|
+
};
|
|
224
248
|
Object.keys(storeObject).forEach(function (storeFieldName) {
|
|
225
249
|
var fieldName = fieldNameFromStoreName(storeFieldName);
|
|
226
250
|
var fieldValue = storeObject[storeFieldName];
|
|
@@ -231,21 +255,19 @@ var EntityStore = (function () {
|
|
|
231
255
|
: fields[storeFieldName] || fields[fieldName];
|
|
232
256
|
if (modify) {
|
|
233
257
|
var newValue = modify === delModifier ? DELETE :
|
|
234
|
-
modify(utilities.maybeDeepFreeze(fieldValue), {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
needToMerge_1 = true;
|
|
248
|
-
fieldValue = newValue;
|
|
258
|
+
modify(utilities.maybeDeepFreeze(fieldValue), tslib.__assign(tslib.__assign({}, sharedDetails_1), { fieldName: fieldName,
|
|
259
|
+
storeFieldName: storeFieldName, storage: _this.getStorage(dataId, storeFieldName) }));
|
|
260
|
+
if (newValue === INVALIDATE) {
|
|
261
|
+
_this.group.dirty(dataId, storeFieldName);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
if (newValue === DELETE)
|
|
265
|
+
newValue = void 0;
|
|
266
|
+
if (newValue !== fieldValue) {
|
|
267
|
+
changedFields_1[storeFieldName] = newValue;
|
|
268
|
+
needToMerge_1 = true;
|
|
269
|
+
fieldValue = newValue;
|
|
270
|
+
}
|
|
249
271
|
}
|
|
250
272
|
}
|
|
251
273
|
if (fieldValue !== void 0) {
|
|
@@ -407,6 +429,7 @@ function makeDepKey(dataId, storeFieldName) {
|
|
|
407
429
|
function Root(_a) {
|
|
408
430
|
var policies = _a.policies, _b = _a.resultCaching, resultCaching = _b === void 0 ? true : _b, seed = _a.seed;
|
|
409
431
|
var _this = _super.call(this, policies, new CacheGroup(resultCaching)) || this;
|
|
432
|
+
_this.storageTrie = new optimism.KeyTrie(utilities.canUseWeakMap);
|
|
410
433
|
_this.sharedLayerGroup = new CacheGroup(resultCaching);
|
|
411
434
|
if (seed)
|
|
412
435
|
_this.replace(seed);
|
|
@@ -418,6 +441,9 @@ function makeDepKey(dataId, storeFieldName) {
|
|
|
418
441
|
Root.prototype.removeLayer = function () {
|
|
419
442
|
return this;
|
|
420
443
|
};
|
|
444
|
+
Root.prototype.getStorage = function (idOrObj, storeFieldName) {
|
|
445
|
+
return this.storageTrie.lookup(idOrObj, storeFieldName);
|
|
446
|
+
};
|
|
421
447
|
return Root;
|
|
422
448
|
}(EntityStore));
|
|
423
449
|
EntityStore.Root = Root;
|
|
@@ -460,6 +486,9 @@ var Layer = (function (_super) {
|
|
|
460
486
|
var fromParent = this.parent.findChildRefIds(dataId);
|
|
461
487
|
return hasOwn.call(this.data, dataId) ? tslib.__assign(tslib.__assign({}, fromParent), _super.prototype.findChildRefIds.call(this, dataId)) : fromParent;
|
|
462
488
|
};
|
|
489
|
+
Layer.prototype.getStorage = function (idOrObj, storeFieldName) {
|
|
490
|
+
return this.parent.getStorage(idOrObj, storeFieldName);
|
|
491
|
+
};
|
|
463
492
|
return Layer;
|
|
464
493
|
}(EntityStore));
|
|
465
494
|
function storeObjectReconciler(existingObject, incomingObject, property) {
|
|
@@ -505,9 +534,6 @@ var StoreReader = (function () {
|
|
|
505
534
|
});
|
|
506
535
|
this.config = tslib.__assign({ addTypename: true }, config);
|
|
507
536
|
}
|
|
508
|
-
StoreReader.prototype.readQueryFromStore = function (options) {
|
|
509
|
-
return this.diffQueryAgainstStore(tslib.__assign(tslib.__assign({}, options), { returnPartialData: false })).result;
|
|
510
|
-
};
|
|
511
537
|
StoreReader.prototype.diffQueryAgainstStore = function (_a) {
|
|
512
538
|
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;
|
|
513
539
|
var policies = this.config.cache.policies;
|
|
@@ -557,7 +583,7 @@ var StoreReader = (function () {
|
|
|
557
583
|
missing: [missingFromInvariant(process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(4) : new tsInvariant.InvariantError("Dangling reference to missing " + objectOrReference.__ref + " object"), context)],
|
|
558
584
|
};
|
|
559
585
|
}
|
|
560
|
-
var
|
|
586
|
+
var variables = context.variables, policies = context.policies, store = context.store;
|
|
561
587
|
var objectsToMerge = [];
|
|
562
588
|
var finalResult = { result: null };
|
|
563
589
|
var typename = store.getFieldValue(objectOrReference, "__typename");
|
|
@@ -626,14 +652,8 @@ var StoreReader = (function () {
|
|
|
626
652
|
tsInvariant.invariant(context.path.pop() === resultName);
|
|
627
653
|
}
|
|
628
654
|
else {
|
|
629
|
-
var fragment =
|
|
630
|
-
if (
|
|
631
|
-
fragment = selection;
|
|
632
|
-
}
|
|
633
|
-
else {
|
|
634
|
-
process.env.NODE_ENV === "production" ? tsInvariant.invariant(fragment = fragmentMap[selection.name.value], 6) : tsInvariant.invariant(fragment = fragmentMap[selection.name.value], "No fragment named " + selection.name.value);
|
|
635
|
-
}
|
|
636
|
-
if (policies.fragmentMatches(fragment, typename)) {
|
|
655
|
+
var fragment = utilities.getFragmentFromSelection(selection, context.fragmentMap);
|
|
656
|
+
if (fragment && policies.fragmentMatches(fragment, typename)) {
|
|
637
657
|
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
638
658
|
}
|
|
639
659
|
}
|
|
@@ -697,7 +717,7 @@ function assertSelectionSetForIdValue(store, field, fieldValue) {
|
|
|
697
717
|
var workSet_1 = new Set([fieldValue]);
|
|
698
718
|
workSet_1.forEach(function (value) {
|
|
699
719
|
if (value && typeof value === "object") {
|
|
700
|
-
process.env.NODE_ENV === "production" ? tsInvariant.invariant(!utilities.isReference(value),
|
|
720
|
+
process.env.NODE_ENV === "production" ? tsInvariant.invariant(!utilities.isReference(value), 6) : tsInvariant.invariant(!utilities.isReference(value), "Missing selection set for object of type " + getTypenameFromStoreObject(store, value) + " returned for query field " + field.name.value);
|
|
701
721
|
Object.values(value).forEach(workSet_1.add, workSet_1);
|
|
702
722
|
}
|
|
703
723
|
});
|
|
@@ -730,7 +750,7 @@ var StoreWriter = (function () {
|
|
|
730
750
|
},
|
|
731
751
|
});
|
|
732
752
|
if (!utilities.isReference(ref)) {
|
|
733
|
-
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(
|
|
753
|
+
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(7) : new tsInvariant.InvariantError("Could not identify object " + JSON.stringify(result));
|
|
734
754
|
}
|
|
735
755
|
store.retain(ref.__ref);
|
|
736
756
|
return ref;
|
|
@@ -793,12 +813,13 @@ var StoreWriter = (function () {
|
|
|
793
813
|
}
|
|
794
814
|
else if (policies.usingPossibleTypes &&
|
|
795
815
|
!utilities.hasDirectives(["defer", "client"], selection)) {
|
|
796
|
-
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(
|
|
816
|
+
throw process.env.NODE_ENV === "production" ? new tsInvariant.InvariantError(8) : new tsInvariant.InvariantError("Missing field '" + resultFieldKey + "' in " + JSON.stringify(result, null, 2).substring(0, 100));
|
|
797
817
|
}
|
|
798
818
|
}
|
|
799
819
|
else {
|
|
800
820
|
var fragment = utilities.getFragmentFromSelection(selection, context.fragmentMap);
|
|
801
|
-
if (fragment &&
|
|
821
|
+
if (fragment &&
|
|
822
|
+
policies.fragmentMatches(fragment, typename, result, context.variables)) {
|
|
802
823
|
fragment.selectionSet.selections.forEach(workSet.add, workSet);
|
|
803
824
|
}
|
|
804
825
|
}
|
|
@@ -955,10 +976,11 @@ var Policies = (function () {
|
|
|
955
976
|
function Policies(config) {
|
|
956
977
|
this.config = config;
|
|
957
978
|
this.typePolicies = Object.create(null);
|
|
979
|
+
this.supertypeMap = new Map();
|
|
980
|
+
this.fuzzySubtypes = new Map();
|
|
958
981
|
this.rootIdsByTypename = Object.create(null);
|
|
959
982
|
this.rootTypenamesById = Object.create(null);
|
|
960
983
|
this.usingPossibleTypes = false;
|
|
961
|
-
this.storageTrie = new optimism.KeyTrie(true);
|
|
962
984
|
this.config = tslib.__assign({ dataIdFromObject: defaultDataIdFromObject }, config);
|
|
963
985
|
this.cache = this.config.cache;
|
|
964
986
|
this.setRootTypename("Query");
|
|
@@ -1061,8 +1083,14 @@ var Policies = (function () {
|
|
|
1061
1083
|
var _this = this;
|
|
1062
1084
|
this.usingPossibleTypes = true;
|
|
1063
1085
|
Object.keys(possibleTypes).forEach(function (supertype) {
|
|
1064
|
-
|
|
1065
|
-
possibleTypes[supertype].forEach(
|
|
1086
|
+
_this.getSupertypeSet(supertype, true);
|
|
1087
|
+
possibleTypes[supertype].forEach(function (subtype) {
|
|
1088
|
+
_this.getSupertypeSet(subtype, true).add(supertype);
|
|
1089
|
+
var match = subtype.match(TypeOrFieldNameRegExp);
|
|
1090
|
+
if (!match || match[0] !== subtype) {
|
|
1091
|
+
_this.fuzzySubtypes.set(subtype, new RegExp(subtype));
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1066
1094
|
});
|
|
1067
1095
|
};
|
|
1068
1096
|
Policies.prototype.getTypePolicy = function (typename, createIfMissing) {
|
|
@@ -1070,12 +1098,6 @@ var Policies = (function () {
|
|
|
1070
1098
|
return this.typePolicies[typename] || (createIfMissing && (this.typePolicies[typename] = Object.create(null)));
|
|
1071
1099
|
}
|
|
1072
1100
|
};
|
|
1073
|
-
Policies.prototype.getSubtypeSet = function (supertype, createIfMissing) {
|
|
1074
|
-
var policy = this.getTypePolicy(supertype, createIfMissing);
|
|
1075
|
-
if (policy) {
|
|
1076
|
-
return policy.subtypes || (createIfMissing ? policy.subtypes = new Set() : void 0);
|
|
1077
|
-
}
|
|
1078
|
-
};
|
|
1079
1101
|
Policies.prototype.getFieldPolicy = function (typename, fieldName, createIfMissing) {
|
|
1080
1102
|
var typePolicy = this.getTypePolicy(typename, createIfMissing);
|
|
1081
1103
|
if (typePolicy) {
|
|
@@ -1085,7 +1107,14 @@ var Policies = (function () {
|
|
|
1085
1107
|
}
|
|
1086
1108
|
}
|
|
1087
1109
|
};
|
|
1088
|
-
Policies.prototype.
|
|
1110
|
+
Policies.prototype.getSupertypeSet = function (subtype, createIfMissing) {
|
|
1111
|
+
var supertypeSet = this.supertypeMap.get(subtype);
|
|
1112
|
+
if (!supertypeSet && createIfMissing) {
|
|
1113
|
+
this.supertypeMap.set(subtype, supertypeSet = new Set());
|
|
1114
|
+
}
|
|
1115
|
+
return supertypeSet;
|
|
1116
|
+
};
|
|
1117
|
+
Policies.prototype.fragmentMatches = function (fragment, typename, result, variables) {
|
|
1089
1118
|
var _this = this;
|
|
1090
1119
|
if (!fragment.typeCondition)
|
|
1091
1120
|
return true;
|
|
@@ -1094,17 +1123,41 @@ var Policies = (function () {
|
|
|
1094
1123
|
var supertype = fragment.typeCondition.name.value;
|
|
1095
1124
|
if (typename === supertype)
|
|
1096
1125
|
return true;
|
|
1097
|
-
if (this.usingPossibleTypes
|
|
1098
|
-
|
|
1126
|
+
if (this.usingPossibleTypes &&
|
|
1127
|
+
this.supertypeMap.has(supertype)) {
|
|
1128
|
+
var typenameSupertypeSet = this.getSupertypeSet(typename, true);
|
|
1129
|
+
var workQueue_1 = [typenameSupertypeSet];
|
|
1130
|
+
var maybeEnqueue_1 = function (subtype) {
|
|
1131
|
+
var supertypeSet = _this.getSupertypeSet(subtype, false);
|
|
1132
|
+
if (supertypeSet &&
|
|
1133
|
+
supertypeSet.size &&
|
|
1134
|
+
workQueue_1.indexOf(supertypeSet) < 0) {
|
|
1135
|
+
workQueue_1.push(supertypeSet);
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
var needToCheckFuzzySubtypes = !!(result && this.fuzzySubtypes.size);
|
|
1139
|
+
var checkingFuzzySubtypes = false;
|
|
1099
1140
|
for (var i = 0; i < workQueue_1.length; ++i) {
|
|
1100
|
-
var
|
|
1101
|
-
if (
|
|
1102
|
-
if (
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1141
|
+
var supertypeSet = workQueue_1[i];
|
|
1142
|
+
if (supertypeSet.has(supertype)) {
|
|
1143
|
+
if (!typenameSupertypeSet.has(supertype)) {
|
|
1144
|
+
if (checkingFuzzySubtypes) {
|
|
1145
|
+
process.env.NODE_ENV === "production" || tsInvariant.invariant.warn("Inferring subtype " + typename + " of supertype " + supertype);
|
|
1146
|
+
}
|
|
1147
|
+
typenameSupertypeSet.add(supertype);
|
|
1148
|
+
}
|
|
1149
|
+
return true;
|
|
1150
|
+
}
|
|
1151
|
+
supertypeSet.forEach(maybeEnqueue_1);
|
|
1152
|
+
if (needToCheckFuzzySubtypes &&
|
|
1153
|
+
i === workQueue_1.length - 1 &&
|
|
1154
|
+
selectionSetMatchesResult(fragment.selectionSet, result, variables)) {
|
|
1155
|
+
needToCheckFuzzySubtypes = false;
|
|
1156
|
+
checkingFuzzySubtypes = true;
|
|
1157
|
+
this.fuzzySubtypes.forEach(function (regExp, fuzzyString) {
|
|
1158
|
+
var match = typename.match(regExp);
|
|
1159
|
+
if (match && match[0] === typename) {
|
|
1160
|
+
maybeEnqueue_1(fuzzyString);
|
|
1108
1161
|
}
|
|
1109
1162
|
});
|
|
1110
1163
|
}
|
|
@@ -1163,7 +1216,7 @@ var Policies = (function () {
|
|
|
1163
1216
|
var policy = this.getFieldPolicy(options.typename, fieldName, false);
|
|
1164
1217
|
var read = policy && policy.read;
|
|
1165
1218
|
if (read) {
|
|
1166
|
-
var readOptions = makeFieldFunctionOptions(this, objectOrReference, options, context,
|
|
1219
|
+
var readOptions = makeFieldFunctionOptions(this, objectOrReference, options, context, context.store.getStorage(utilities.isReference(objectOrReference)
|
|
1167
1220
|
? objectOrReference.__ref
|
|
1168
1221
|
: objectOrReference, storeFieldName));
|
|
1169
1222
|
return cacheSlot.withValue(this.cache, read, [existing, readOptions]);
|
|
@@ -1175,16 +1228,15 @@ var Policies = (function () {
|
|
|
1175
1228
|
return !!(policy && policy.merge);
|
|
1176
1229
|
};
|
|
1177
1230
|
Policies.prototype.applyMerges = function (existing, incoming, context, storageKeys) {
|
|
1231
|
+
var _a;
|
|
1178
1232
|
var _this = this;
|
|
1179
1233
|
if (isFieldValueToBeMerged(incoming)) {
|
|
1180
1234
|
var field = incoming.__field;
|
|
1181
1235
|
var fieldName = field.name.value;
|
|
1182
1236
|
var merge = this.getFieldPolicy(incoming.__typename, fieldName, false).merge;
|
|
1183
|
-
var storage = storageKeys
|
|
1184
|
-
? this.storageTrie.lookupArray(storageKeys)
|
|
1185
|
-
: null;
|
|
1186
1237
|
incoming = merge(existing, incoming.__value, makeFieldFunctionOptions(this, void 0, { typename: incoming.__typename, fieldName: fieldName,
|
|
1187
|
-
field: field, variables: context.variables }, context,
|
|
1238
|
+
field: field, variables: context.variables }, context, storageKeys
|
|
1239
|
+
? (_a = context.store).getStorage.apply(_a, storageKeys) : Object.create(null)));
|
|
1188
1240
|
}
|
|
1189
1241
|
if (Array.isArray(incoming)) {
|
|
1190
1242
|
return incoming.map(function (item) { return _this.applyMerges(void 0, item, context); });
|
|
@@ -1394,13 +1446,14 @@ var InMemoryCache = (function (_super) {
|
|
|
1394
1446
|
if (typeof options.rootId === 'string' && !store.has(options.rootId)) {
|
|
1395
1447
|
return null;
|
|
1396
1448
|
}
|
|
1397
|
-
return this.storeReader.
|
|
1449
|
+
return this.storeReader.diffQueryAgainstStore({
|
|
1398
1450
|
store: store,
|
|
1399
1451
|
query: options.query,
|
|
1400
1452
|
variables: options.variables,
|
|
1401
1453
|
rootId: options.rootId,
|
|
1402
1454
|
config: this.config,
|
|
1403
|
-
|
|
1455
|
+
returnPartialData: false,
|
|
1456
|
+
}).result || null;
|
|
1404
1457
|
};
|
|
1405
1458
|
InMemoryCache.prototype.write = function (options) {
|
|
1406
1459
|
try {
|