@apollo/client 3.9.0-alpha.1 → 3.9.0-alpha.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/apollo-client.cjs +96 -104
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +6 -29
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +6 -29
- package/cache/index.d.ts +1 -2
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +1 -2
- package/cache/index.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +1 -2
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts +0 -5
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +0 -22
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +0 -2
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +1 -2
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +5 -6
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +0 -2
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +0 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.js +2 -2
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +8 -11
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +8 -11
- package/dev/dev.cjs +28 -19
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +28 -19
- package/dev/loadErrorMessageHandler.js +1 -1
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/package.json +6 -6
- package/testing/internal/ObservableStream.d.ts +26 -0
- package/testing/internal/ObservableStream.d.ts.map +1 -0
- package/testing/internal/ObservableStream.js +101 -0
- package/testing/internal/ObservableStream.js.map +1 -0
- package/testing/internal/index.d.ts +1 -0
- package/testing/internal/index.d.ts.map +1 -1
- package/testing/internal/index.js +1 -0
- package/testing/internal/index.js.map +1 -1
- package/utilities/common/canonicalStringify.d.ts +4 -0
- package/utilities/common/canonicalStringify.d.ts.map +1 -0
- package/utilities/common/canonicalStringify.js +37 -0
- package/utilities/common/canonicalStringify.js.map +1 -0
- package/utilities/globals/globals.cjs +29 -19
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +29 -19
- package/utilities/globals/invariantWrappers.d.ts.map +1 -1
- package/utilities/globals/invariantWrappers.js +28 -18
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +2 -2
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +7 -19
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/index.d.ts +1 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/asyncMap.d.ts.map +1 -1
- package/utilities/observables/asyncMap.js +17 -34
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/utilities.cjs +61 -53
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +61 -53
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -31,7 +31,7 @@ function _interopNamespace(e) {
|
|
|
31
31
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
32
32
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
33
33
|
|
|
34
|
-
var version = "3.9.0-alpha.
|
|
34
|
+
var version = "3.9.0-alpha.2";
|
|
35
35
|
|
|
36
36
|
function maybe(thunk) {
|
|
37
37
|
try {
|
|
@@ -71,11 +71,14 @@ function wrap(fn) {
|
|
|
71
71
|
args[_i - 1] = arguments[_i];
|
|
72
72
|
}
|
|
73
73
|
if (typeof message === "number") {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
var arg0 = message;
|
|
75
|
+
message = getHandledErrorMsg(arg0);
|
|
76
|
+
if (!message) {
|
|
77
|
+
message = getFallbackErrorMsg(arg0, args);
|
|
78
|
+
args = [];
|
|
79
|
+
}
|
|
78
80
|
}
|
|
81
|
+
fn.apply(void 0, [message].concat(args));
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
84
|
var invariant = Object.assign(function invariant(condition, message) {
|
|
@@ -84,7 +87,7 @@ var invariant = Object.assign(function invariant(condition, message) {
|
|
|
84
87
|
args[_i - 2] = arguments[_i];
|
|
85
88
|
}
|
|
86
89
|
if (!condition) {
|
|
87
|
-
tsInvariant.invariant(condition,
|
|
90
|
+
tsInvariant.invariant(condition, getHandledErrorMsg(message, args) || getFallbackErrorMsg(message, args));
|
|
88
91
|
}
|
|
89
92
|
}, {
|
|
90
93
|
debug: wrap(tsInvariant.invariant.debug),
|
|
@@ -97,23 +100,31 @@ function newInvariantError(message) {
|
|
|
97
100
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
98
101
|
optionalParams[_i - 1] = arguments[_i];
|
|
99
102
|
}
|
|
100
|
-
return new tsInvariant.InvariantError(
|
|
103
|
+
return new tsInvariant.InvariantError(getHandledErrorMsg(message, optionalParams) ||
|
|
104
|
+
getFallbackErrorMsg(message, optionalParams));
|
|
101
105
|
}
|
|
102
106
|
var ApolloErrorMessageHandler = Symbol.for("ApolloErrorMessageHandler_" + version);
|
|
103
|
-
function
|
|
107
|
+
function stringify(arg) {
|
|
108
|
+
return typeof arg == "string"
|
|
109
|
+
? arg
|
|
110
|
+
: stringifyForDisplay(arg, 2).slice(0, 1000);
|
|
111
|
+
}
|
|
112
|
+
function getHandledErrorMsg(message, messageArgs) {
|
|
104
113
|
if (messageArgs === void 0) { messageArgs = []; }
|
|
105
114
|
if (!message)
|
|
106
115
|
return;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
return (global$1[ApolloErrorMessageHandler] &&
|
|
117
|
+
global$1[ApolloErrorMessageHandler](message, messageArgs.map(stringify)));
|
|
118
|
+
}
|
|
119
|
+
function getFallbackErrorMsg(message, messageArgs) {
|
|
120
|
+
if (messageArgs === void 0) { messageArgs = []; }
|
|
121
|
+
if (!message)
|
|
122
|
+
return;
|
|
123
|
+
return "An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({
|
|
124
|
+
version: version,
|
|
125
|
+
message: message,
|
|
126
|
+
args: messageArgs.map(stringify),
|
|
127
|
+
})));
|
|
117
128
|
}
|
|
118
129
|
|
|
119
130
|
function shouldInclude(_a, variables) {
|
|
@@ -252,6 +263,43 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
252
263
|
}
|
|
253
264
|
}
|
|
254
265
|
|
|
266
|
+
var canonicalStringify = Object.assign(function canonicalStringify(value) {
|
|
267
|
+
return JSON.stringify(value, stableObjectReplacer);
|
|
268
|
+
}, {
|
|
269
|
+
reset: function () {
|
|
270
|
+
sortingMap.clear();
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
var sortingMap = new Map();
|
|
274
|
+
function stableObjectReplacer(key, value) {
|
|
275
|
+
if (value && typeof value === "object") {
|
|
276
|
+
var proto = Object.getPrototypeOf(value);
|
|
277
|
+
if (proto === Object.prototype || proto === null) {
|
|
278
|
+
var keys = Object.keys(value);
|
|
279
|
+
if (keys.every(everyKeyInOrder))
|
|
280
|
+
return value;
|
|
281
|
+
var unsortedKey = JSON.stringify(keys);
|
|
282
|
+
var sortedKeys = sortingMap.get(unsortedKey);
|
|
283
|
+
if (!sortedKeys) {
|
|
284
|
+
keys.sort();
|
|
285
|
+
var sortedKey = JSON.stringify(keys);
|
|
286
|
+
sortedKeys = sortingMap.get(sortedKey) || keys;
|
|
287
|
+
sortingMap.set(unsortedKey, sortedKeys);
|
|
288
|
+
sortingMap.set(sortedKey, sortedKeys);
|
|
289
|
+
}
|
|
290
|
+
var sortedObject_1 = Object.create(proto);
|
|
291
|
+
sortedKeys.forEach(function (key) {
|
|
292
|
+
sortedObject_1[key] = value[key];
|
|
293
|
+
});
|
|
294
|
+
return sortedObject_1;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
return value;
|
|
298
|
+
}
|
|
299
|
+
function everyKeyInOrder(key, i, keys) {
|
|
300
|
+
return i === 0 || keys[i - 1] <= key;
|
|
301
|
+
}
|
|
302
|
+
|
|
255
303
|
function makeReference(id) {
|
|
256
304
|
return { __ref: String(id) };
|
|
257
305
|
}
|
|
@@ -358,6 +406,7 @@ var KNOWN_DIRECTIVES = [
|
|
|
358
406
|
"export",
|
|
359
407
|
"nonreactive",
|
|
360
408
|
];
|
|
409
|
+
var storeKeyNameStringify = canonicalStringify;
|
|
361
410
|
var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
362
411
|
if (args &&
|
|
363
412
|
directives &&
|
|
@@ -373,7 +422,7 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
373
422
|
filterKeys.forEach(function (key) {
|
|
374
423
|
filteredArgs_1[key] = args[key];
|
|
375
424
|
});
|
|
376
|
-
return "".concat(directives["connection"]["key"], "(").concat(
|
|
425
|
+
return "".concat(directives["connection"]["key"], "(").concat(storeKeyNameStringify(filteredArgs_1), ")");
|
|
377
426
|
}
|
|
378
427
|
else {
|
|
379
428
|
return directives["connection"]["key"];
|
|
@@ -381,7 +430,7 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
381
430
|
}
|
|
382
431
|
var completeFieldName = fieldName;
|
|
383
432
|
if (args) {
|
|
384
|
-
var stringifiedArgs =
|
|
433
|
+
var stringifiedArgs = storeKeyNameStringify(args);
|
|
385
434
|
completeFieldName += "(".concat(stringifiedArgs, ")");
|
|
386
435
|
}
|
|
387
436
|
if (directives) {
|
|
@@ -389,7 +438,7 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
389
438
|
if (KNOWN_DIRECTIVES.indexOf(key) !== -1)
|
|
390
439
|
return;
|
|
391
440
|
if (directives[key] && Object.keys(directives[key]).length) {
|
|
392
|
-
completeFieldName += "@".concat(key, "(").concat(
|
|
441
|
+
completeFieldName += "@".concat(key, "(").concat(storeKeyNameStringify(directives[key]), ")");
|
|
393
442
|
}
|
|
394
443
|
else {
|
|
395
444
|
completeFieldName += "@".concat(key);
|
|
@@ -399,25 +448,11 @@ var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
|
399
448
|
return completeFieldName;
|
|
400
449
|
}, {
|
|
401
450
|
setStringify: function (s) {
|
|
402
|
-
var previous =
|
|
403
|
-
|
|
451
|
+
var previous = storeKeyNameStringify;
|
|
452
|
+
storeKeyNameStringify = s;
|
|
404
453
|
return previous;
|
|
405
454
|
},
|
|
406
455
|
});
|
|
407
|
-
var stringify = function defaultStringify(value) {
|
|
408
|
-
return JSON.stringify(value, stringifyReplacer);
|
|
409
|
-
};
|
|
410
|
-
function stringifyReplacer(_key, value) {
|
|
411
|
-
if (isNonNullObject(value) && !Array.isArray(value)) {
|
|
412
|
-
value = Object.keys(value)
|
|
413
|
-
.sort()
|
|
414
|
-
.reduce(function (copy, key) {
|
|
415
|
-
copy[key] = value[key];
|
|
416
|
-
return copy;
|
|
417
|
-
}, {});
|
|
418
|
-
}
|
|
419
|
-
return value;
|
|
420
|
-
}
|
|
421
456
|
function argumentsObjectFromField(field, variables) {
|
|
422
457
|
if (field.arguments && field.arguments.length) {
|
|
423
458
|
var argObj_1 = {};
|
|
@@ -1092,48 +1127,31 @@ function iterateObserversSafely(observers, method, argument) {
|
|
|
1092
1127
|
|
|
1093
1128
|
function asyncMap(observable, mapFn, catchFn) {
|
|
1094
1129
|
return new zenObservableTs.Observable(function (observer) {
|
|
1095
|
-
var next = observer.next, error = observer.error, complete = observer.complete;
|
|
1096
|
-
var activeCallbackCount = 0;
|
|
1097
|
-
var completed = false;
|
|
1098
1130
|
var promiseQueue = {
|
|
1099
1131
|
then: function (callback) {
|
|
1100
1132
|
return new Promise(function (resolve) { return resolve(callback()); });
|
|
1101
1133
|
},
|
|
1102
1134
|
};
|
|
1103
|
-
function makeCallback(examiner,
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
--activeCallbackCount;
|
|
1118
|
-
throw error;
|
|
1119
|
-
})
|
|
1120
|
-
.catch(function (caught) {
|
|
1121
|
-
error && error.call(observer, caught);
|
|
1122
|
-
});
|
|
1123
|
-
};
|
|
1124
|
-
}
|
|
1125
|
-
else {
|
|
1126
|
-
return function (arg) { return delegate && delegate.call(observer, arg); };
|
|
1127
|
-
}
|
|
1135
|
+
function makeCallback(examiner, key) {
|
|
1136
|
+
return function (arg) {
|
|
1137
|
+
if (examiner) {
|
|
1138
|
+
var both = function () {
|
|
1139
|
+
return observer.closed
|
|
1140
|
+
? 0
|
|
1141
|
+
: examiner(arg);
|
|
1142
|
+
};
|
|
1143
|
+
promiseQueue = promiseQueue.then(both, both).then(function (result) { return observer.next(result); }, function (error) { return observer.error(error); });
|
|
1144
|
+
}
|
|
1145
|
+
else {
|
|
1146
|
+
observer[key](arg);
|
|
1147
|
+
}
|
|
1148
|
+
};
|
|
1128
1149
|
}
|
|
1129
1150
|
var handler = {
|
|
1130
|
-
next: makeCallback(mapFn, next),
|
|
1131
|
-
error: makeCallback(catchFn, error),
|
|
1151
|
+
next: makeCallback(mapFn, "next"),
|
|
1152
|
+
error: makeCallback(catchFn, "error"),
|
|
1132
1153
|
complete: function () {
|
|
1133
|
-
|
|
1134
|
-
if (!activeCallbackCount) {
|
|
1135
|
-
complete && complete.call(observer);
|
|
1136
|
-
}
|
|
1154
|
+
promiseQueue.then(function () { return observer.complete(); });
|
|
1137
1155
|
},
|
|
1138
1156
|
};
|
|
1139
1157
|
var sub = observable.subscribe(handler);
|
|
@@ -2962,28 +2980,6 @@ var ObjectCanon = (function () {
|
|
|
2962
2980
|
};
|
|
2963
2981
|
return ObjectCanon;
|
|
2964
2982
|
}());
|
|
2965
|
-
var canonicalStringify = Object.assign(function (value) {
|
|
2966
|
-
if (isNonNullObject(value)) {
|
|
2967
|
-
if (stringifyCanon === void 0) {
|
|
2968
|
-
resetCanonicalStringify();
|
|
2969
|
-
}
|
|
2970
|
-
var canonical = stringifyCanon.admit(value);
|
|
2971
|
-
var json = stringifyCache.get(canonical);
|
|
2972
|
-
if (json === void 0) {
|
|
2973
|
-
stringifyCache.set(canonical, (json = JSON.stringify(canonical)));
|
|
2974
|
-
}
|
|
2975
|
-
return json;
|
|
2976
|
-
}
|
|
2977
|
-
return JSON.stringify(value);
|
|
2978
|
-
}, {
|
|
2979
|
-
reset: resetCanonicalStringify,
|
|
2980
|
-
});
|
|
2981
|
-
var stringifyCanon;
|
|
2982
|
-
var stringifyCache;
|
|
2983
|
-
function resetCanonicalStringify() {
|
|
2984
|
-
stringifyCanon = new ObjectCanon();
|
|
2985
|
-
stringifyCache = new (canUseWeakMap ? WeakMap : Map)();
|
|
2986
|
-
}
|
|
2987
2983
|
|
|
2988
2984
|
function execSelectionSetKeyArgs(options) {
|
|
2989
2985
|
return [
|
|
@@ -3435,7 +3431,6 @@ function normalize(value) {
|
|
|
3435
3431
|
return value;
|
|
3436
3432
|
}
|
|
3437
3433
|
|
|
3438
|
-
getStoreKeyName.setStringify(canonicalStringify);
|
|
3439
3434
|
function argsFromFieldSpecifier(spec) {
|
|
3440
3435
|
return spec.args !== void 0
|
|
3441
3436
|
? spec.args
|
|
@@ -5007,9 +5002,9 @@ var ObservableQuery = (function (_super) {
|
|
|
5007
5002
|
}
|
|
5008
5003
|
return options.fetchPolicy;
|
|
5009
5004
|
};
|
|
5010
|
-
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
5005
|
+
ObservableQuery.prototype.fetch = function (options, newNetworkStatus, query) {
|
|
5011
5006
|
this.queryManager.setObservableQuery(this);
|
|
5012
|
-
return this.queryManager["fetchConcastWithInfo"](this.queryId, options, newNetworkStatus);
|
|
5007
|
+
return this.queryManager["fetchConcastWithInfo"](this.queryId, options, newNetworkStatus, query);
|
|
5013
5008
|
};
|
|
5014
5009
|
ObservableQuery.prototype.updatePolling = function () {
|
|
5015
5010
|
var _this = this;
|
|
@@ -5091,15 +5086,14 @@ var ObservableQuery = (function (_super) {
|
|
|
5091
5086
|
}
|
|
5092
5087
|
}
|
|
5093
5088
|
}
|
|
5094
|
-
|
|
5095
|
-
this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(fetchOptions.fetchPolicy));
|
|
5089
|
+
this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy));
|
|
5096
5090
|
var finishWaitingForOwnResult = function () {
|
|
5097
5091
|
if (_this.concast === concast) {
|
|
5098
5092
|
_this.waitForOwnResult = false;
|
|
5099
5093
|
}
|
|
5100
5094
|
};
|
|
5101
|
-
var variables =
|
|
5102
|
-
var _a = this.fetch(
|
|
5095
|
+
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
5096
|
+
var _a = this.fetch(options, newNetworkStatus, query), concast = _a.concast, fromLink = _a.fromLink;
|
|
5103
5097
|
var observer = {
|
|
5104
5098
|
next: function (result) {
|
|
5105
5099
|
finishWaitingForOwnResult();
|
|
@@ -5541,7 +5535,6 @@ var QueryInfo = (function () {
|
|
|
5541
5535
|
this.listeners = new Set();
|
|
5542
5536
|
this.document = null;
|
|
5543
5537
|
this.lastRequestId = 1;
|
|
5544
|
-
this.subscriptions = new Set();
|
|
5545
5538
|
this.stopped = false;
|
|
5546
5539
|
this.dirty = false;
|
|
5547
5540
|
this.observableQuery = null;
|
|
@@ -5676,7 +5669,6 @@ var QueryInfo = (function () {
|
|
|
5676
5669
|
this.reset();
|
|
5677
5670
|
this.cancel();
|
|
5678
5671
|
this.cancel = QueryInfo.prototype.cancel;
|
|
5679
|
-
this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
|
|
5680
5672
|
var oq = this.observableQuery;
|
|
5681
5673
|
if (oq)
|
|
5682
5674
|
oq.stopPolling();
|
|
@@ -6455,10 +6447,10 @@ var QueryManager = (function () {
|
|
|
6455
6447
|
throw error;
|
|
6456
6448
|
});
|
|
6457
6449
|
};
|
|
6458
|
-
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
|
|
6450
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus, query) {
|
|
6459
6451
|
var _this = this;
|
|
6460
6452
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
6461
|
-
|
|
6453
|
+
if (query === void 0) { query = options.query; }
|
|
6462
6454
|
var variables = this.getVariables(query, options.variables);
|
|
6463
6455
|
var queryInfo = this.getQuery(queryId);
|
|
6464
6456
|
var defaults = this.defaultOptions.watchQuery;
|