@apollo/client 3.8.0-alpha.11 → 3.8.0-alpha.12
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 +452 -281
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +2 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +30 -19
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +2 -0
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +60 -48
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +175 -82
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +175 -82
- package/core/equalByQuery.d.ts +4 -0
- package/core/equalByQuery.d.ts.map +1 -0
- package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
- package/core/equalByQuery.js.map +1 -0
- package/core/index.d.ts +1 -1
- package/core/index.d.ts.map +1 -1
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/errors/errors.cjs +17 -17
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +17 -17
- package/errors/index.d.ts +24 -8
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +17 -19
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +1 -1
- package/link/batch-http/batch-http.cjs +23 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +23 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +7 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/core/types.d.ts +4 -0
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +21 -20
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +59 -30
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +59 -30
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +34 -14
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +2 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/subscriptions/index.d.ts.map +1 -1
- package/link/subscriptions/index.js +10 -5
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +9 -4
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +9 -4
- package/link/utils/filterOperationVariables.d.ts +5 -0
- package/link/utils/filterOperationVariables.d.ts.map +1 -0
- package/link/utils/filterOperationVariables.js +18 -0
- package/link/utils/filterOperationVariables.js.map +1 -0
- package/link/utils/index.d.ts +1 -0
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +1 -0
- package/link/utils/index.js.map +1 -1
- package/link/utils/utils.cjs +18 -0
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +18 -0
- package/package.json +17 -17
- package/react/cache/QuerySubscription.js +1 -1
- package/react/cache/QuerySubscription.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +3 -2
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js +6 -7
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/hooks/hooks.cjs +61 -84
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +61 -84
- package/react/hooks/internal/__use.d.ts +3 -1
- package/react/hooks/internal/__use.d.ts.map +1 -1
- package/react/hooks/internal/__use.js +16 -12
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +13 -22
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +3 -3
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +26 -25
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +6 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/index.d.ts +1 -1
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -1
- package/react/index.js.map +1 -1
- package/react/react.cjs +7 -22
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +7 -22
- package/react/types/types.d.ts +1 -0
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/react/MockedProvider.d.ts +1 -1
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +7 -6
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +8 -124
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +8 -124
- package/utilities/common/incrementalResult.d.ts +2 -1
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js +4 -0
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/objects.d.ts +1 -0
- package/utilities/common/objects.d.ts.map +1 -1
- package/utilities/common/objects.js +6 -0
- package/utilities/common/objects.js.map +1 -1
- package/utilities/common/omitDeep.d.ts +3 -0
- package/utilities/common/omitDeep.d.ts.map +1 -0
- package/utilities/common/omitDeep.js +42 -0
- package/utilities/common/omitDeep.js.map +1 -0
- package/utilities/common/stripTypename.d.ts +2 -0
- package/utilities/common/stripTypename.d.ts.map +1 -0
- package/utilities/common/stripTypename.js +5 -0
- package/utilities/common/stripTypename.js.map +1 -0
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -0
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +26 -16
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +4 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +3 -0
- package/utilities/index.js.map +1 -1
- package/utilities/types/DeepOmit.d.ts +9 -0
- package/utilities/types/DeepOmit.d.ts.map +1 -0
- package/utilities/types/DeepOmit.js +2 -0
- package/utilities/types/DeepOmit.js.map +1 -0
- package/utilities/utilities.cjs +111 -15
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +111 -15
- package/version.js +1 -1
- package/react/hooks/compareResults.d.ts +0 -3
- package/react/hooks/compareResults.d.ts.map +0 -1
- package/react/hooks/compareResults.js.map +0 -1
package/apollo-client.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var tslib = require('tslib');
|
|
|
6
6
|
var tsInvariant = require('ts-invariant');
|
|
7
7
|
var process$1 = require('ts-invariant/process');
|
|
8
8
|
var graphql = require('graphql');
|
|
9
|
-
var
|
|
9
|
+
var equal = require('@wry/equality');
|
|
10
10
|
var zenObservableTs = require('zen-observable-ts');
|
|
11
11
|
require('symbol-observable');
|
|
12
12
|
var optimism = require('optimism');
|
|
@@ -15,6 +15,8 @@ var trie = require('@wry/trie');
|
|
|
15
15
|
var graphqlTag = require('graphql-tag');
|
|
16
16
|
var React = require('react');
|
|
17
17
|
|
|
18
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
19
|
+
|
|
18
20
|
function _interopNamespace(e) {
|
|
19
21
|
if (e && e.__esModule) return e;
|
|
20
22
|
var n = Object.create(null);
|
|
@@ -27,7 +29,9 @@ function _interopNamespace(e) {
|
|
|
27
29
|
return Object.freeze(n);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
30
33
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
31
35
|
|
|
32
36
|
function maybe(thunk) {
|
|
33
37
|
try {
|
|
@@ -178,6 +182,12 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
178
182
|
function isNonNullObject(obj) {
|
|
179
183
|
return obj !== null && typeof obj === 'object';
|
|
180
184
|
}
|
|
185
|
+
function isPlainObject(obj) {
|
|
186
|
+
return (obj !== null &&
|
|
187
|
+
typeof obj === 'object' &&
|
|
188
|
+
(Object.getPrototypeOf(obj) === Object.prototype ||
|
|
189
|
+
Object.getPrototypeOf(obj) === null));
|
|
190
|
+
}
|
|
181
191
|
|
|
182
192
|
function makeReference(id) {
|
|
183
193
|
return { __ref: String(id) };
|
|
@@ -285,6 +295,7 @@ var KNOWN_DIRECTIVES = [
|
|
|
285
295
|
'client',
|
|
286
296
|
'rest',
|
|
287
297
|
'export',
|
|
298
|
+
'nonreactive',
|
|
288
299
|
];
|
|
289
300
|
var getStoreKeyName = Object.assign(function (fieldName, args, directives) {
|
|
290
301
|
if (args &&
|
|
@@ -483,19 +494,30 @@ function nullIfDocIsEmpty(doc) {
|
|
|
483
494
|
? null
|
|
484
495
|
: doc;
|
|
485
496
|
}
|
|
486
|
-
function getDirectiveMatcher(
|
|
487
|
-
var
|
|
488
|
-
var tests =
|
|
489
|
-
|
|
490
|
-
if (directive
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
497
|
+
function getDirectiveMatcher(configs) {
|
|
498
|
+
var names = new Map();
|
|
499
|
+
var tests = new Map();
|
|
500
|
+
configs.forEach(function (directive) {
|
|
501
|
+
if (directive) {
|
|
502
|
+
if (directive.name) {
|
|
503
|
+
names.set(directive.name, directive);
|
|
504
|
+
}
|
|
505
|
+
else if (directive.test) {
|
|
506
|
+
tests.set(directive.test, directive);
|
|
507
|
+
}
|
|
495
508
|
}
|
|
496
509
|
});
|
|
497
|
-
return function (directive) {
|
|
498
|
-
|
|
510
|
+
return function (directive) {
|
|
511
|
+
var config = names.get(directive.name.value);
|
|
512
|
+
if (!config && tests.size) {
|
|
513
|
+
tests.forEach(function (testConfig, test) {
|
|
514
|
+
if (test(directive)) {
|
|
515
|
+
config = testConfig;
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
return config;
|
|
520
|
+
};
|
|
499
521
|
}
|
|
500
522
|
function makeInUseGetterFunction(defaultKey) {
|
|
501
523
|
var map = new Map();
|
|
@@ -512,6 +534,7 @@ function makeInUseGetterFunction(defaultKey) {
|
|
|
512
534
|
};
|
|
513
535
|
}
|
|
514
536
|
function removeDirectivesFromDocument(directives, doc) {
|
|
537
|
+
checkDocument(doc);
|
|
515
538
|
var getInUseByOperationName = makeInUseGetterFunction("");
|
|
516
539
|
var getInUseByFragmentName = makeInUseGetterFunction("");
|
|
517
540
|
var getInUse = function (ancestors) {
|
|
@@ -535,10 +558,8 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
535
558
|
}
|
|
536
559
|
}
|
|
537
560
|
var directiveMatcher = getDirectiveMatcher(directives);
|
|
538
|
-
var
|
|
539
|
-
|
|
540
|
-
nodeDirectives &&
|
|
541
|
-
nodeDirectives.some(directiveMatcher)); };
|
|
561
|
+
var shouldRemoveField = function (nodeDirectives) { return (isNonEmptyArray(nodeDirectives) &&
|
|
562
|
+
nodeDirectives.map(directiveMatcher).some(function (config) { return config && config.remove; })); };
|
|
542
563
|
var originalFragmentDefsByPath = new Map();
|
|
543
564
|
var firstVisitMadeChanges = false;
|
|
544
565
|
var fieldOrInlineFragmentVisitor = {
|
|
@@ -697,22 +718,6 @@ var addTypenameToDocument = Object.assign(function (doc) {
|
|
|
697
718
|
return field === TYPENAME_FIELD;
|
|
698
719
|
},
|
|
699
720
|
});
|
|
700
|
-
var connectionRemoveConfig = {
|
|
701
|
-
test: function (directive) {
|
|
702
|
-
var willRemove = directive.name.value === 'connection';
|
|
703
|
-
if (willRemove) {
|
|
704
|
-
if (!directive.arguments ||
|
|
705
|
-
!directive.arguments.some(function (arg) { return arg.name.value === 'key'; })) {
|
|
706
|
-
__DEV__ && tsInvariant.invariant.warn('Removing an @connection directive even though it does not have a key. ' +
|
|
707
|
-
'You may want to use the key parameter to specify a store key.');
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
return willRemove;
|
|
711
|
-
},
|
|
712
|
-
};
|
|
713
|
-
function removeConnectionDirectiveFromDocument(doc) {
|
|
714
|
-
return removeDirectivesFromDocument([connectionRemoveConfig], checkDocument(doc));
|
|
715
|
-
}
|
|
716
721
|
function buildQueryFromSelectionSet(document) {
|
|
717
722
|
var definition = getMainDefinition(document);
|
|
718
723
|
var definitionOperation = definition.operation;
|
|
@@ -812,6 +817,31 @@ var DeepMerger = (function () {
|
|
|
812
817
|
return DeepMerger;
|
|
813
818
|
}());
|
|
814
819
|
|
|
820
|
+
function isStatefulPromise(promise) {
|
|
821
|
+
return 'status' in promise;
|
|
822
|
+
}
|
|
823
|
+
function wrapPromiseWithState(promise) {
|
|
824
|
+
if (isStatefulPromise(promise)) {
|
|
825
|
+
return promise;
|
|
826
|
+
}
|
|
827
|
+
var pendingPromise = promise;
|
|
828
|
+
pendingPromise.status = 'pending';
|
|
829
|
+
pendingPromise.then(function (value) {
|
|
830
|
+
if (pendingPromise.status === 'pending') {
|
|
831
|
+
var fulfilledPromise = pendingPromise;
|
|
832
|
+
fulfilledPromise.status = 'fulfilled';
|
|
833
|
+
fulfilledPromise.value = value;
|
|
834
|
+
}
|
|
835
|
+
}, function (reason) {
|
|
836
|
+
if (pendingPromise.status === 'pending') {
|
|
837
|
+
var rejectedPromise = pendingPromise;
|
|
838
|
+
rejectedPromise.status = 'rejected';
|
|
839
|
+
rejectedPromise.reason = reason;
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
return promise;
|
|
843
|
+
}
|
|
844
|
+
|
|
815
845
|
var toString = Object.prototype.toString;
|
|
816
846
|
function cloneDeep(value) {
|
|
817
847
|
return cloneDeepHelper(value);
|
|
@@ -1094,6 +1124,9 @@ function isExecutionPatchResult(value) {
|
|
|
1094
1124
|
return (isExecutionPatchIncrementalResult(value) ||
|
|
1095
1125
|
isExecutionPatchInitialResult(value));
|
|
1096
1126
|
}
|
|
1127
|
+
function isApolloPayloadResult(value) {
|
|
1128
|
+
return isNonNullObject(value) && "payload" in value;
|
|
1129
|
+
}
|
|
1097
1130
|
function mergeIncrementalData(prevResult, result) {
|
|
1098
1131
|
var mergedData = prevResult;
|
|
1099
1132
|
var merger = new DeepMerger();
|
|
@@ -1192,6 +1225,51 @@ function isNodeReadableStream(value) {
|
|
|
1192
1225
|
return !!value.pipe;
|
|
1193
1226
|
}
|
|
1194
1227
|
|
|
1228
|
+
function omitDeep(value, key) {
|
|
1229
|
+
return __omitDeep(value, key);
|
|
1230
|
+
}
|
|
1231
|
+
function __omitDeep(value, key, known) {
|
|
1232
|
+
if (known === void 0) { known = new Map(); }
|
|
1233
|
+
if (known.has(value)) {
|
|
1234
|
+
return known.get(value);
|
|
1235
|
+
}
|
|
1236
|
+
var modified = false;
|
|
1237
|
+
if (Array.isArray(value)) {
|
|
1238
|
+
var array_1 = [];
|
|
1239
|
+
known.set(value, array_1);
|
|
1240
|
+
value.forEach(function (value, index) {
|
|
1241
|
+
var result = __omitDeep(value, key, known);
|
|
1242
|
+
modified || (modified = result !== value);
|
|
1243
|
+
array_1[index] = result;
|
|
1244
|
+
});
|
|
1245
|
+
if (modified) {
|
|
1246
|
+
return array_1;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
else if (isPlainObject(value)) {
|
|
1250
|
+
var obj_1 = Object.create(Object.getPrototypeOf(value));
|
|
1251
|
+
known.set(value, obj_1);
|
|
1252
|
+
Object.keys(value).forEach(function (k) {
|
|
1253
|
+
if (k === key) {
|
|
1254
|
+
modified = true;
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
var result = __omitDeep(value[k], key, known);
|
|
1258
|
+
modified || (modified = result !== value[k]);
|
|
1259
|
+
obj_1[k] = result;
|
|
1260
|
+
}
|
|
1261
|
+
});
|
|
1262
|
+
if (modified) {
|
|
1263
|
+
return obj_1;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
return value;
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
function stripTypename(value) {
|
|
1270
|
+
return omitDeep(value, '__typename');
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1195
1273
|
function fromError(errorValue) {
|
|
1196
1274
|
return new zenObservableTs.Observable(function (observer) {
|
|
1197
1275
|
observer.error(errorValue);
|
|
@@ -1291,6 +1369,22 @@ function transformOperation(operation) {
|
|
|
1291
1369
|
return transformedOperation;
|
|
1292
1370
|
}
|
|
1293
1371
|
|
|
1372
|
+
function filterOperationVariables(variables, operation) {
|
|
1373
|
+
var result = tslib.__assign({}, variables);
|
|
1374
|
+
var unusedNames = new Set(Object.keys(variables));
|
|
1375
|
+
graphql.visit(operation.query, {
|
|
1376
|
+
Variable: function (node, _key, parent) {
|
|
1377
|
+
if (parent && parent.kind !== 'VariableDefinition') {
|
|
1378
|
+
unusedNames.delete(node.name.value);
|
|
1379
|
+
}
|
|
1380
|
+
},
|
|
1381
|
+
});
|
|
1382
|
+
unusedNames.forEach(function (name) {
|
|
1383
|
+
delete result[name];
|
|
1384
|
+
});
|
|
1385
|
+
return result;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1294
1388
|
function passthrough(op, forward) {
|
|
1295
1389
|
return (forward ? forward(op) : zenObservableTs.Observable.of());
|
|
1296
1390
|
}
|
|
@@ -1396,7 +1490,7 @@ var concat = ApolloLink.concat;
|
|
|
1396
1490
|
|
|
1397
1491
|
var execute = ApolloLink.execute;
|
|
1398
1492
|
|
|
1399
|
-
var version = '3.8.0-alpha.
|
|
1493
|
+
var version = '3.8.0-alpha.12';
|
|
1400
1494
|
|
|
1401
1495
|
function asyncIterator(source) {
|
|
1402
1496
|
var _a;
|
|
@@ -1541,20 +1635,56 @@ function responseIterator(response) {
|
|
|
1541
1635
|
throw new Error("Unknown body type for responseIterator. Please pass a streamable response.");
|
|
1542
1636
|
}
|
|
1543
1637
|
|
|
1638
|
+
var PROTOCOL_ERRORS_SYMBOL = Symbol();
|
|
1639
|
+
function graphQLResultHasProtocolErrors(result) {
|
|
1640
|
+
if (result.extensions) {
|
|
1641
|
+
return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);
|
|
1642
|
+
}
|
|
1643
|
+
return false;
|
|
1644
|
+
}
|
|
1645
|
+
function isApolloError(err) {
|
|
1646
|
+
return err.hasOwnProperty('graphQLErrors');
|
|
1647
|
+
}
|
|
1648
|
+
var generateErrorMessage = function (err) {
|
|
1649
|
+
var errors = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);
|
|
1650
|
+
if (err.networkError)
|
|
1651
|
+
errors.push(err.networkError);
|
|
1652
|
+
return errors
|
|
1653
|
+
.map(function (err) { return isNonNullObject(err) && err.message || 'Error message not found.'; })
|
|
1654
|
+
.join('\n');
|
|
1655
|
+
};
|
|
1656
|
+
var ApolloError = (function (_super) {
|
|
1657
|
+
tslib.__extends(ApolloError, _super);
|
|
1658
|
+
function ApolloError(_a) {
|
|
1659
|
+
var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
1660
|
+
var _this = _super.call(this, errorMessage) || this;
|
|
1661
|
+
_this.name = 'ApolloError';
|
|
1662
|
+
_this.graphQLErrors = graphQLErrors || [];
|
|
1663
|
+
_this.protocolErrors = protocolErrors || [];
|
|
1664
|
+
_this.clientErrors = clientErrors || [];
|
|
1665
|
+
_this.networkError = networkError || null;
|
|
1666
|
+
_this.message = errorMessage || generateErrorMessage(_this);
|
|
1667
|
+
_this.extraInfo = extraInfo;
|
|
1668
|
+
_this.__proto__ = ApolloError.prototype;
|
|
1669
|
+
return _this;
|
|
1670
|
+
}
|
|
1671
|
+
return ApolloError;
|
|
1672
|
+
}(Error));
|
|
1673
|
+
|
|
1544
1674
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1545
1675
|
function readMultipartBody(response, observer) {
|
|
1546
|
-
var _a, _b, _c;
|
|
1676
|
+
var _a, _b, _c, _d, _e;
|
|
1547
1677
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1548
|
-
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running,
|
|
1549
|
-
var
|
|
1550
|
-
return tslib.__generator(this, function (
|
|
1551
|
-
switch (
|
|
1678
|
+
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _f, value, done, chunk, bi, message, i, headers, contentType_1, body, result, next;
|
|
1679
|
+
var _g, _h;
|
|
1680
|
+
return tslib.__generator(this, function (_j) {
|
|
1681
|
+
switch (_j.label) {
|
|
1552
1682
|
case 0:
|
|
1553
1683
|
if (TextDecoder === undefined) {
|
|
1554
1684
|
throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
|
|
1555
1685
|
}
|
|
1556
1686
|
decoder = new TextDecoder("utf-8");
|
|
1557
|
-
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get(
|
|
1687
|
+
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get("content-type");
|
|
1558
1688
|
delimiter = "boundary=";
|
|
1559
1689
|
boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter))
|
|
1560
1690
|
? contentType === null || contentType === void 0 ? void 0 : contentType.substring((contentType === null || contentType === void 0 ? void 0 : contentType.indexOf(delimiter)) + delimiter.length).replace(/['"]/g, "").replace(/\;(.*)/gm, "").trim()
|
|
@@ -1563,22 +1693,22 @@ function readMultipartBody(response, observer) {
|
|
|
1563
1693
|
buffer = "";
|
|
1564
1694
|
iterator = responseIterator(response);
|
|
1565
1695
|
running = true;
|
|
1566
|
-
|
|
1696
|
+
_j.label = 1;
|
|
1567
1697
|
case 1:
|
|
1568
1698
|
if (!running) return [3, 3];
|
|
1569
1699
|
return [4, iterator.next()];
|
|
1570
1700
|
case 2:
|
|
1571
|
-
|
|
1701
|
+
_f = _j.sent(), value = _f.value, done = _f.done;
|
|
1572
1702
|
chunk = typeof value === "string" ? value : decoder.decode(value);
|
|
1573
1703
|
running = !done;
|
|
1574
1704
|
buffer += chunk;
|
|
1575
1705
|
bi = buffer.indexOf(boundary);
|
|
1576
1706
|
while (bi > -1) {
|
|
1577
1707
|
message = void 0;
|
|
1578
|
-
|
|
1708
|
+
_g = [
|
|
1579
1709
|
buffer.slice(0, bi),
|
|
1580
1710
|
buffer.slice(bi + boundary.length),
|
|
1581
|
-
], message =
|
|
1711
|
+
], message = _g[0], buffer = _g[1];
|
|
1582
1712
|
if (message.trim()) {
|
|
1583
1713
|
i = message.indexOf("\r\n\r\n");
|
|
1584
1714
|
headers = parseHeaders(message.slice(0, i));
|
|
@@ -1593,8 +1723,26 @@ function readMultipartBody(response, observer) {
|
|
|
1593
1723
|
if (Object.keys(result).length > 1 ||
|
|
1594
1724
|
"data" in result ||
|
|
1595
1725
|
"incremental" in result ||
|
|
1596
|
-
"errors" in result
|
|
1597
|
-
|
|
1726
|
+
"errors" in result ||
|
|
1727
|
+
"payload" in result) {
|
|
1728
|
+
if (isApolloPayloadResult(result)) {
|
|
1729
|
+
next = {};
|
|
1730
|
+
if ("payload" in result) {
|
|
1731
|
+
next = tslib.__assign({}, result.payload);
|
|
1732
|
+
}
|
|
1733
|
+
if ("errors" in result) {
|
|
1734
|
+
next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_h = {}, _h[PROTOCOL_ERRORS_SYMBOL] = result.errors, _h)) });
|
|
1735
|
+
}
|
|
1736
|
+
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, next);
|
|
1737
|
+
}
|
|
1738
|
+
else {
|
|
1739
|
+
(_c = observer.next) === null || _c === void 0 ? void 0 : _c.call(observer, result);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
else if (Object.keys(result).length === 1 &&
|
|
1743
|
+
"hasNext" in result &&
|
|
1744
|
+
!result.hasNext) {
|
|
1745
|
+
(_d = observer.complete) === null || _d === void 0 ? void 0 : _d.call(observer);
|
|
1598
1746
|
}
|
|
1599
1747
|
}
|
|
1600
1748
|
catch (err) {
|
|
@@ -1605,7 +1753,7 @@ function readMultipartBody(response, observer) {
|
|
|
1605
1753
|
}
|
|
1606
1754
|
return [3, 1];
|
|
1607
1755
|
case 3:
|
|
1608
|
-
(
|
|
1756
|
+
(_e = observer.complete) === null || _e === void 0 ? void 0 : _e.call(observer);
|
|
1609
1757
|
return [2];
|
|
1610
1758
|
}
|
|
1611
1759
|
});
|
|
@@ -1744,7 +1892,7 @@ function selectHttpOptionsAndBodyInternal(operation, printer) {
|
|
|
1744
1892
|
options.headers = removeDuplicateHeaders(options.headers, http.preserveHeaderCase);
|
|
1745
1893
|
}
|
|
1746
1894
|
var operationName = operation.operationName, extensions = operation.extensions, variables = operation.variables, query = operation.query;
|
|
1747
|
-
var body = { operationName: operationName, variables: variables };
|
|
1895
|
+
var body = { operationName: operationName, variables: stripTypename(variables) };
|
|
1748
1896
|
if (http.includeExtensions)
|
|
1749
1897
|
body.extensions = extensions;
|
|
1750
1898
|
if (http.includeQuery)
|
|
@@ -1885,20 +2033,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
1885
2033
|
}
|
|
1886
2034
|
var _b = selectHttpOptionsAndBodyInternal(operation, print, fallbackHttpConfig, linkConfig, contextConfig), options = _b.options, body = _b.body;
|
|
1887
2035
|
if (body.variables && !includeUnusedVariables) {
|
|
1888
|
-
|
|
1889
|
-
graphql.visit(operation.query, {
|
|
1890
|
-
Variable: function (node, _key, parent) {
|
|
1891
|
-
if (parent && parent.kind !== 'VariableDefinition') {
|
|
1892
|
-
unusedNames_1.delete(node.name.value);
|
|
1893
|
-
}
|
|
1894
|
-
},
|
|
1895
|
-
});
|
|
1896
|
-
if (unusedNames_1.size) {
|
|
1897
|
-
body.variables = tslib.__assign({}, body.variables);
|
|
1898
|
-
unusedNames_1.forEach(function (name) {
|
|
1899
|
-
delete body.variables[name];
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
2036
|
+
body.variables = filterOperationVariables(body.variables, operation);
|
|
1902
2037
|
}
|
|
1903
2038
|
var controller;
|
|
1904
2039
|
if (!options.signal) {
|
|
@@ -1910,13 +2045,28 @@ var createHttpLink = function (linkOptions) {
|
|
|
1910
2045
|
var definitionIsMutation = function (d) {
|
|
1911
2046
|
return d.kind === 'OperationDefinition' && d.operation === 'mutation';
|
|
1912
2047
|
};
|
|
2048
|
+
var definitionIsSubscription = function (d) {
|
|
2049
|
+
return d.kind === 'OperationDefinition' && d.operation === 'subscription';
|
|
2050
|
+
};
|
|
2051
|
+
var isSubscription = definitionIsSubscription(getMainDefinition(operation.query));
|
|
2052
|
+
var hasDefer = hasDirectives(['defer'], operation.query);
|
|
1913
2053
|
if (useGETForQueries &&
|
|
1914
2054
|
!operation.query.definitions.some(definitionIsMutation)) {
|
|
1915
2055
|
options.method = 'GET';
|
|
1916
2056
|
}
|
|
1917
|
-
if (
|
|
2057
|
+
if (hasDefer || isSubscription) {
|
|
1918
2058
|
options.headers = options.headers || {};
|
|
1919
|
-
|
|
2059
|
+
var acceptHeader = "multipart/mixed;";
|
|
2060
|
+
if (isSubscription && hasDefer) {
|
|
2061
|
+
__DEV__ && tsInvariant.invariant.warn("Multipart-subscriptions do not support @defer");
|
|
2062
|
+
}
|
|
2063
|
+
if (isSubscription) {
|
|
2064
|
+
acceptHeader += 'boundary=graphql;subscriptionSpec=1.0,application/json';
|
|
2065
|
+
}
|
|
2066
|
+
else if (hasDefer) {
|
|
2067
|
+
acceptHeader += 'deferSpec=20220824,application/json';
|
|
2068
|
+
}
|
|
2069
|
+
options.headers.accept = acceptHeader;
|
|
1920
2070
|
}
|
|
1921
2071
|
if (options.method === 'GET') {
|
|
1922
2072
|
var _d = rewriteURIForGET(chosenURI, body), newURI = _d.newURI, parseError = _d.parseError;
|
|
@@ -2568,7 +2718,7 @@ var Layer = (function (_super) {
|
|
|
2568
2718
|
}
|
|
2569
2719
|
else if (ownStoreObject !== parentStoreObject) {
|
|
2570
2720
|
Object.keys(ownStoreObject).forEach(function (storeFieldName) {
|
|
2571
|
-
if (!
|
|
2721
|
+
if (!equal.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
|
|
2572
2722
|
_this.group.dirty(dataId, storeFieldName);
|
|
2573
2723
|
}
|
|
2574
2724
|
});
|
|
@@ -2612,7 +2762,7 @@ var Stump = (function (_super) {
|
|
|
2612
2762
|
function storeObjectReconciler(existingObject, incomingObject, property) {
|
|
2613
2763
|
var existingValue = existingObject[property];
|
|
2614
2764
|
var incomingValue = incomingObject[property];
|
|
2615
|
-
return
|
|
2765
|
+
return equal.equal(existingValue, incomingValue) ? existingValue : incomingValue;
|
|
2616
2766
|
}
|
|
2617
2767
|
function supportsResultCaching(store) {
|
|
2618
2768
|
return !!(store instanceof EntityStore && store.group.caching);
|
|
@@ -3939,7 +4089,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
|
|
|
3939
4089
|
return;
|
|
3940
4090
|
if (isReference(existing))
|
|
3941
4091
|
return;
|
|
3942
|
-
if (
|
|
4092
|
+
if (equal.equal(existing, incoming))
|
|
3943
4093
|
return;
|
|
3944
4094
|
if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
|
|
3945
4095
|
return;
|
|
@@ -4262,51 +4412,13 @@ var InMemoryCache = (function (_super) {
|
|
|
4262
4412
|
return;
|
|
4263
4413
|
}
|
|
4264
4414
|
}
|
|
4265
|
-
if (!lastDiff || !
|
|
4415
|
+
if (!lastDiff || !equal.equal(lastDiff.result, diff.result)) {
|
|
4266
4416
|
c.callback(c.lastDiff = diff, lastDiff);
|
|
4267
4417
|
}
|
|
4268
4418
|
};
|
|
4269
4419
|
return InMemoryCache;
|
|
4270
4420
|
}(ApolloCache));
|
|
4271
4421
|
|
|
4272
|
-
function isApolloError(err) {
|
|
4273
|
-
return err.hasOwnProperty('graphQLErrors');
|
|
4274
|
-
}
|
|
4275
|
-
var generateErrorMessage = function (err) {
|
|
4276
|
-
var message = '';
|
|
4277
|
-
if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {
|
|
4278
|
-
var errors = (err.graphQLErrors || [])
|
|
4279
|
-
.concat(err.clientErrors || []);
|
|
4280
|
-
errors.forEach(function (error) {
|
|
4281
|
-
var errorMessage = error
|
|
4282
|
-
? error.message
|
|
4283
|
-
: 'Error message not found.';
|
|
4284
|
-
message += "".concat(errorMessage, "\n");
|
|
4285
|
-
});
|
|
4286
|
-
}
|
|
4287
|
-
if (err.networkError) {
|
|
4288
|
-
message += "".concat(err.networkError.message, "\n");
|
|
4289
|
-
}
|
|
4290
|
-
message = message.replace(/\n$/, '');
|
|
4291
|
-
return message;
|
|
4292
|
-
};
|
|
4293
|
-
var ApolloError = (function (_super) {
|
|
4294
|
-
tslib.__extends(ApolloError, _super);
|
|
4295
|
-
function ApolloError(_a) {
|
|
4296
|
-
var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
4297
|
-
var _this = _super.call(this, errorMessage) || this;
|
|
4298
|
-
_this.name = 'ApolloError';
|
|
4299
|
-
_this.graphQLErrors = graphQLErrors || [];
|
|
4300
|
-
_this.clientErrors = clientErrors || [];
|
|
4301
|
-
_this.networkError = networkError || null;
|
|
4302
|
-
_this.message = errorMessage || generateErrorMessage(_this);
|
|
4303
|
-
_this.extraInfo = extraInfo;
|
|
4304
|
-
_this.__proto__ = ApolloError.prototype;
|
|
4305
|
-
return _this;
|
|
4306
|
-
}
|
|
4307
|
-
return ApolloError;
|
|
4308
|
-
}(Error));
|
|
4309
|
-
|
|
4310
4422
|
exports.NetworkStatus = void 0;
|
|
4311
4423
|
(function (NetworkStatus) {
|
|
4312
4424
|
NetworkStatus[NetworkStatus["loading"] = 1] = "loading";
|
|
@@ -4324,6 +4436,70 @@ function isNetworkRequestSettled(networkStatus) {
|
|
|
4324
4436
|
return networkStatus === 7 || networkStatus === 8;
|
|
4325
4437
|
}
|
|
4326
4438
|
|
|
4439
|
+
function equalByQuery(query, _a, _b, variables) {
|
|
4440
|
+
var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
|
|
4441
|
+
var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
|
|
4442
|
+
return equal__default(aRest, bRest) && equalBySelectionSet(getMainDefinition(query).selectionSet, aData, bData, {
|
|
4443
|
+
fragmentMap: createFragmentMap(getFragmentDefinitions(query)),
|
|
4444
|
+
variables: variables,
|
|
4445
|
+
});
|
|
4446
|
+
}
|
|
4447
|
+
function equalBySelectionSet(selectionSet, aResult, bResult, context) {
|
|
4448
|
+
if (aResult === bResult) {
|
|
4449
|
+
return true;
|
|
4450
|
+
}
|
|
4451
|
+
var seenSelections = new Set();
|
|
4452
|
+
return selectionSet.selections.every(function (selection) {
|
|
4453
|
+
if (seenSelections.has(selection))
|
|
4454
|
+
return true;
|
|
4455
|
+
seenSelections.add(selection);
|
|
4456
|
+
if (!shouldInclude(selection, context.variables))
|
|
4457
|
+
return true;
|
|
4458
|
+
if (selectionHasNonreactiveDirective(selection))
|
|
4459
|
+
return true;
|
|
4460
|
+
if (isField(selection)) {
|
|
4461
|
+
var resultKey = resultKeyNameFromField(selection);
|
|
4462
|
+
var aResultChild = aResult && aResult[resultKey];
|
|
4463
|
+
var bResultChild = bResult && bResult[resultKey];
|
|
4464
|
+
var childSelectionSet = selection.selectionSet;
|
|
4465
|
+
if (!childSelectionSet) {
|
|
4466
|
+
return equal__default(aResultChild, bResultChild);
|
|
4467
|
+
}
|
|
4468
|
+
var aChildIsArray = Array.isArray(aResultChild);
|
|
4469
|
+
var bChildIsArray = Array.isArray(bResultChild);
|
|
4470
|
+
if (aChildIsArray !== bChildIsArray)
|
|
4471
|
+
return false;
|
|
4472
|
+
if (aChildIsArray && bChildIsArray) {
|
|
4473
|
+
var length_1 = aResultChild.length;
|
|
4474
|
+
if (bResultChild.length !== length_1) {
|
|
4475
|
+
return false;
|
|
4476
|
+
}
|
|
4477
|
+
for (var i = 0; i < length_1; ++i) {
|
|
4478
|
+
if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
|
|
4479
|
+
return false;
|
|
4480
|
+
}
|
|
4481
|
+
}
|
|
4482
|
+
return true;
|
|
4483
|
+
}
|
|
4484
|
+
return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
|
|
4485
|
+
}
|
|
4486
|
+
else {
|
|
4487
|
+
var fragment = getFragmentFromSelection(selection, context.fragmentMap);
|
|
4488
|
+
if (fragment) {
|
|
4489
|
+
if (selectionHasNonreactiveDirective(fragment))
|
|
4490
|
+
return true;
|
|
4491
|
+
return equalBySelectionSet(fragment.selectionSet, aResult, bResult, context);
|
|
4492
|
+
}
|
|
4493
|
+
}
|
|
4494
|
+
});
|
|
4495
|
+
}
|
|
4496
|
+
function selectionHasNonreactiveDirective(selection) {
|
|
4497
|
+
return !!selection.directives && selection.directives.some(directiveIsNonreactive);
|
|
4498
|
+
}
|
|
4499
|
+
function directiveIsNonreactive(dir) {
|
|
4500
|
+
return dir.name.value === "nonreactive";
|
|
4501
|
+
}
|
|
4502
|
+
|
|
4327
4503
|
var assign = Object.assign, hasOwnProperty$2 = Object.hasOwnProperty;
|
|
4328
4504
|
var ObservableQuery = (function (_super) {
|
|
4329
4505
|
tslib.__extends(ObservableQuery, _super);
|
|
@@ -4418,7 +4594,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4418
4594
|
if (diff.complete || this.options.returnPartialData) {
|
|
4419
4595
|
result.data = diff.result;
|
|
4420
4596
|
}
|
|
4421
|
-
if (
|
|
4597
|
+
if (equal.equal(result.data, {})) {
|
|
4422
4598
|
result.data = void 0;
|
|
4423
4599
|
}
|
|
4424
4600
|
if (diff.complete) {
|
|
@@ -4449,15 +4625,21 @@ var ObservableQuery = (function (_super) {
|
|
|
4449
4625
|
return result;
|
|
4450
4626
|
};
|
|
4451
4627
|
ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4628
|
+
if (!this.last) {
|
|
4629
|
+
return true;
|
|
4630
|
+
}
|
|
4631
|
+
var query = this.options.query;
|
|
4632
|
+
var resultIsDifferent = this.queryManager.transform(query).hasNonreactiveDirective
|
|
4633
|
+
? !equalByQuery(query, this.last.result, newResult, this.variables)
|
|
4634
|
+
: !equal.equal(this.last.result, newResult);
|
|
4635
|
+
return (resultIsDifferent ||
|
|
4636
|
+
(variables && !equal.equal(this.last.variables, variables)));
|
|
4455
4637
|
};
|
|
4456
4638
|
ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
|
|
4457
4639
|
var last = this.last;
|
|
4458
4640
|
if (last &&
|
|
4459
4641
|
last[key] &&
|
|
4460
|
-
(!variablesMustMatch ||
|
|
4642
|
+
(!variablesMustMatch || equal.equal(last.variables, this.variables))) {
|
|
4461
4643
|
return last[key];
|
|
4462
4644
|
}
|
|
4463
4645
|
};
|
|
@@ -4496,7 +4678,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4496
4678
|
__DEV__ && tsInvariant.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
|
|
4497
4679
|
}
|
|
4498
4680
|
}
|
|
4499
|
-
if (variables && !
|
|
4681
|
+
if (variables && !equal.equal(this.options.variables, variables)) {
|
|
4500
4682
|
reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
|
|
4501
4683
|
}
|
|
4502
4684
|
this.queryInfo.resetLastWrite();
|
|
@@ -4591,7 +4773,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4591
4773
|
return this.reobserve(newOptions);
|
|
4592
4774
|
};
|
|
4593
4775
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
4594
|
-
if (
|
|
4776
|
+
if (equal.equal(this.variables, variables)) {
|
|
4595
4777
|
return this.observers.size
|
|
4596
4778
|
? this.result()
|
|
4597
4779
|
: Promise.resolve();
|
|
@@ -4656,7 +4838,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4656
4838
|
};
|
|
4657
4839
|
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
4658
4840
|
this.queryManager.setObservableQuery(this);
|
|
4659
|
-
return this.queryManager
|
|
4841
|
+
return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
|
|
4660
4842
|
};
|
|
4661
4843
|
ObservableQuery.prototype.updatePolling = function () {
|
|
4662
4844
|
var _this = this;
|
|
@@ -4701,15 +4883,15 @@ var ObservableQuery = (function (_super) {
|
|
|
4701
4883
|
};
|
|
4702
4884
|
ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
|
|
4703
4885
|
if (variables === void 0) { variables = this.variables; }
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
if (!isNonEmptyArray(newResult.errors)) {
|
|
4708
|
-
delete this.last.error;
|
|
4886
|
+
var error = this.getLastError();
|
|
4887
|
+
if (error && this.last && !equal.equal(variables, this.last.variables)) {
|
|
4888
|
+
error = void 0;
|
|
4709
4889
|
}
|
|
4710
|
-
return this.last
|
|
4890
|
+
return this.last = tslib.__assign({ result: this.queryManager.assumeImmutableResults
|
|
4891
|
+
? newResult
|
|
4892
|
+
: cloneDeep(newResult), variables: variables }, (error ? { error: error } : null));
|
|
4711
4893
|
};
|
|
4712
|
-
ObservableQuery.prototype.
|
|
4894
|
+
ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
|
|
4713
4895
|
var _this = this;
|
|
4714
4896
|
this.isTornDown = false;
|
|
4715
4897
|
var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
|
|
@@ -4725,7 +4907,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4725
4907
|
this.updatePolling();
|
|
4726
4908
|
if (newOptions &&
|
|
4727
4909
|
newOptions.variables &&
|
|
4728
|
-
!
|
|
4910
|
+
!equal.equal(newOptions.variables, oldVariables) &&
|
|
4729
4911
|
options.fetchPolicy !== "standby" &&
|
|
4730
4912
|
options.fetchPolicy === oldFetchPolicy) {
|
|
4731
4913
|
this.applyNextFetchPolicy("variables-changed", options);
|
|
@@ -4735,7 +4917,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4735
4917
|
}
|
|
4736
4918
|
}
|
|
4737
4919
|
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
4738
|
-
var
|
|
4920
|
+
var _a = this.fetch(options, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
4739
4921
|
var observer = {
|
|
4740
4922
|
next: function (result) {
|
|
4741
4923
|
_this.reportResult(result, variables);
|
|
@@ -4744,7 +4926,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4744
4926
|
_this.reportError(error, variables);
|
|
4745
4927
|
},
|
|
4746
4928
|
};
|
|
4747
|
-
if (!useDisposableConcast) {
|
|
4929
|
+
if (!useDisposableConcast && (fromLink || !this.concast)) {
|
|
4748
4930
|
if (this.concast && this.observer) {
|
|
4749
4931
|
this.concast.removeObserver(this.observer);
|
|
4750
4932
|
}
|
|
@@ -4752,18 +4934,22 @@ var ObservableQuery = (function (_super) {
|
|
|
4752
4934
|
this.observer = observer;
|
|
4753
4935
|
}
|
|
4754
4936
|
concast.addObserver(observer);
|
|
4755
|
-
return concast
|
|
4937
|
+
return concast;
|
|
4938
|
+
};
|
|
4939
|
+
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
4940
|
+
return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;
|
|
4756
4941
|
};
|
|
4757
4942
|
ObservableQuery.prototype.observe = function () {
|
|
4758
4943
|
this.reportResult(this.getCurrentResult(false), this.variables);
|
|
4759
4944
|
};
|
|
4760
4945
|
ObservableQuery.prototype.reportResult = function (result, variables) {
|
|
4761
4946
|
var lastError = this.getLastError();
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4947
|
+
var isDifferent = this.isDifferentFromLastResult(result, variables);
|
|
4948
|
+
if (lastError || !result.partial || this.options.returnPartialData) {
|
|
4949
|
+
this.updateLastResult(result, variables);
|
|
4950
|
+
}
|
|
4951
|
+
if (lastError || isDifferent) {
|
|
4952
|
+
iterateObserversSafely(this.observers, "next", result);
|
|
4767
4953
|
}
|
|
4768
4954
|
};
|
|
4769
4955
|
ObservableQuery.prototype.reportError = function (error, variables) {
|
|
@@ -5172,10 +5358,10 @@ var QueryInfo = (function () {
|
|
|
5172
5358
|
var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
|
|
5173
5359
|
if (this.variables &&
|
|
5174
5360
|
this.networkStatus !== exports.NetworkStatus.loading &&
|
|
5175
|
-
!
|
|
5361
|
+
!equal.equal(this.variables, query.variables)) {
|
|
5176
5362
|
networkStatus = exports.NetworkStatus.setVariables;
|
|
5177
5363
|
}
|
|
5178
|
-
if (!
|
|
5364
|
+
if (!equal.equal(query.variables, this.variables)) {
|
|
5179
5365
|
this.lastDiff = void 0;
|
|
5180
5366
|
}
|
|
5181
5367
|
Object.assign(this, {
|
|
@@ -5200,7 +5386,7 @@ var QueryInfo = (function () {
|
|
|
5200
5386
|
QueryInfo.prototype.getDiff = function (variables) {
|
|
5201
5387
|
if (variables === void 0) { variables = this.variables; }
|
|
5202
5388
|
var options = this.getDiffOptions(variables);
|
|
5203
|
-
if (this.lastDiff &&
|
|
5389
|
+
if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
|
|
5204
5390
|
return this.lastDiff.diff;
|
|
5205
5391
|
}
|
|
5206
5392
|
this.updateWatch(this.variables = variables);
|
|
@@ -5234,7 +5420,7 @@ var QueryInfo = (function () {
|
|
|
5234
5420
|
var oldDiff = this.lastDiff && this.lastDiff.diff;
|
|
5235
5421
|
this.updateLastDiff(diff);
|
|
5236
5422
|
if (!this.dirty &&
|
|
5237
|
-
!
|
|
5423
|
+
!equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
|
|
5238
5424
|
this.dirty = true;
|
|
5239
5425
|
if (!this.notifyTimeout) {
|
|
5240
5426
|
this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
|
|
@@ -5309,7 +5495,7 @@ var QueryInfo = (function () {
|
|
|
5309
5495
|
}
|
|
5310
5496
|
var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
|
|
5311
5497
|
if (!this.lastWatch ||
|
|
5312
|
-
!
|
|
5498
|
+
!equal.equal(watchOptions, this.lastWatch)) {
|
|
5313
5499
|
this.cancel();
|
|
5314
5500
|
this.cancel = this.cache.watch(this.lastWatch = watchOptions);
|
|
5315
5501
|
}
|
|
@@ -5321,8 +5507,8 @@ var QueryInfo = (function () {
|
|
|
5321
5507
|
var lastWrite = this.lastWrite;
|
|
5322
5508
|
return !(lastWrite &&
|
|
5323
5509
|
lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
|
|
5324
|
-
|
|
5325
|
-
|
|
5510
|
+
equal.equal(variables, lastWrite.variables) &&
|
|
5511
|
+
equal.equal(result.data, lastWrite.result.data));
|
|
5326
5512
|
};
|
|
5327
5513
|
QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
|
|
5328
5514
|
var _this = this;
|
|
@@ -5724,14 +5910,17 @@ var QueryManager = (function () {
|
|
|
5724
5910
|
var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
5725
5911
|
if (!transformCache.has(document)) {
|
|
5726
5912
|
var transformed = this.cache.transformDocument(document);
|
|
5727
|
-
var
|
|
5913
|
+
var serverQuery = removeDirectivesFromDocument([
|
|
5914
|
+
removeClientFields ? { name: 'client', remove: true } : {},
|
|
5915
|
+
{ name: 'connection' },
|
|
5916
|
+
{ name: 'nonreactive' },
|
|
5917
|
+
], transformed);
|
|
5728
5918
|
var clientQuery = this.localState.clientQuery(transformed);
|
|
5729
|
-
var serverQuery = noConnection &&
|
|
5730
|
-
this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
|
|
5731
5919
|
var cacheEntry_1 = {
|
|
5732
5920
|
document: transformed,
|
|
5733
5921
|
hasClientExports: hasClientExports(transformed),
|
|
5734
5922
|
hasForcedResolvers: this.localState.shouldForceResolvers(transformed),
|
|
5923
|
+
hasNonreactiveDirective: hasDirectives(['nonreactive'], transformed),
|
|
5735
5924
|
clientQuery: clientQuery,
|
|
5736
5925
|
serverQuery: serverQuery,
|
|
5737
5926
|
defaultVars: getDefaultValues(getOperationDefinition(transformed)),
|
|
@@ -5929,10 +6118,17 @@ var QueryManager = (function () {
|
|
|
5929
6118
|
}
|
|
5930
6119
|
_this.broadcastQueries();
|
|
5931
6120
|
}
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
}
|
|
6121
|
+
var hasErrors = graphQLResultHasError(result);
|
|
6122
|
+
var hasProtocolErrors = graphQLResultHasProtocolErrors(result);
|
|
6123
|
+
if (hasErrors || hasProtocolErrors) {
|
|
6124
|
+
var errors = {};
|
|
6125
|
+
if (hasErrors) {
|
|
6126
|
+
errors.graphQLErrors = result.errors;
|
|
6127
|
+
}
|
|
6128
|
+
if (hasProtocolErrors) {
|
|
6129
|
+
errors.protocolErrors = result.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
6130
|
+
}
|
|
6131
|
+
throw new ApolloError(errors);
|
|
5936
6132
|
}
|
|
5937
6133
|
return result;
|
|
5938
6134
|
});
|
|
@@ -6064,6 +6260,9 @@ var QueryManager = (function () {
|
|
|
6064
6260
|
});
|
|
6065
6261
|
};
|
|
6066
6262
|
QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
|
|
6263
|
+
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast;
|
|
6264
|
+
};
|
|
6265
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
|
|
6067
6266
|
var _this = this;
|
|
6068
6267
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
6069
6268
|
var query = this.transform(options.query).document;
|
|
@@ -6082,24 +6281,36 @@ var QueryManager = (function () {
|
|
|
6082
6281
|
});
|
|
6083
6282
|
var fromVariables = function (variables) {
|
|
6084
6283
|
normalized.variables = variables;
|
|
6085
|
-
var
|
|
6284
|
+
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
6086
6285
|
if (normalized.fetchPolicy !== "standby" &&
|
|
6087
|
-
|
|
6286
|
+
sourcesWithInfo.sources.length > 0 &&
|
|
6088
6287
|
queryInfo.observableQuery) {
|
|
6089
6288
|
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
6090
6289
|
}
|
|
6091
|
-
return
|
|
6290
|
+
return sourcesWithInfo;
|
|
6092
6291
|
};
|
|
6093
6292
|
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
6094
6293
|
this.fetchCancelFns.set(queryId, function (reason) {
|
|
6095
6294
|
cleanupCancelFn();
|
|
6096
6295
|
setTimeout(function () { return concast.cancel(reason); });
|
|
6097
6296
|
});
|
|
6098
|
-
var concast
|
|
6099
|
-
|
|
6100
|
-
|
|
6297
|
+
var concast, containsDataFromLink;
|
|
6298
|
+
if (this.transform(normalized.query).hasClientExports) {
|
|
6299
|
+
concast = new Concast(this.localState
|
|
6300
|
+
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
6301
|
+
.then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
6302
|
+
containsDataFromLink = true;
|
|
6303
|
+
}
|
|
6304
|
+
else {
|
|
6305
|
+
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
6306
|
+
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
6307
|
+
concast = new Concast(sourcesWithInfo.sources);
|
|
6308
|
+
}
|
|
6101
6309
|
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
6102
|
-
return
|
|
6310
|
+
return {
|
|
6311
|
+
concast: concast,
|
|
6312
|
+
fromLink: containsDataFromLink,
|
|
6313
|
+
};
|
|
6103
6314
|
};
|
|
6104
6315
|
QueryManager.prototype.refetchQueries = function (_a) {
|
|
6105
6316
|
var _this = this;
|
|
@@ -6184,7 +6395,7 @@ var QueryManager = (function () {
|
|
|
6184
6395
|
var data = diff.result;
|
|
6185
6396
|
if (__DEV__ &&
|
|
6186
6397
|
!returnPartialData &&
|
|
6187
|
-
!
|
|
6398
|
+
!equal.equal(data, {})) {
|
|
6188
6399
|
logMissingFieldErrors(diff.missing);
|
|
6189
6400
|
}
|
|
6190
6401
|
var fromData = function (data) { return zenObservableTs.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
|
|
@@ -6223,54 +6434,40 @@ var QueryManager = (function () {
|
|
|
6223
6434
|
case "cache-first": {
|
|
6224
6435
|
var diff = readCache();
|
|
6225
6436
|
if (diff.complete) {
|
|
6226
|
-
return [
|
|
6227
|
-
resultsFromCache(diff, queryInfo.markReady()),
|
|
6228
|
-
];
|
|
6437
|
+
return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
|
|
6229
6438
|
}
|
|
6230
6439
|
if (returnPartialData || shouldNotify) {
|
|
6231
|
-
return [
|
|
6232
|
-
resultsFromCache(diff),
|
|
6233
|
-
resultsFromLink(),
|
|
6234
|
-
];
|
|
6440
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6235
6441
|
}
|
|
6236
|
-
return [
|
|
6237
|
-
resultsFromLink(),
|
|
6238
|
-
];
|
|
6442
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6239
6443
|
}
|
|
6240
6444
|
case "cache-and-network": {
|
|
6241
6445
|
var diff = readCache();
|
|
6242
6446
|
if (diff.complete || returnPartialData || shouldNotify) {
|
|
6243
|
-
return [
|
|
6244
|
-
resultsFromCache(diff),
|
|
6245
|
-
resultsFromLink(),
|
|
6246
|
-
];
|
|
6447
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6247
6448
|
}
|
|
6248
|
-
return [
|
|
6249
|
-
resultsFromLink(),
|
|
6250
|
-
];
|
|
6449
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6251
6450
|
}
|
|
6252
6451
|
case "cache-only":
|
|
6253
|
-
return [
|
|
6254
|
-
resultsFromCache(readCache(), queryInfo.markReady()),
|
|
6255
|
-
];
|
|
6452
|
+
return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
|
|
6256
6453
|
case "network-only":
|
|
6257
6454
|
if (shouldNotify) {
|
|
6258
|
-
return [
|
|
6259
|
-
resultsFromCache(readCache()),
|
|
6260
|
-
resultsFromLink(),
|
|
6261
|
-
];
|
|
6455
|
+
return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
|
|
6262
6456
|
}
|
|
6263
|
-
return [resultsFromLink()];
|
|
6457
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6264
6458
|
case "no-cache":
|
|
6265
6459
|
if (shouldNotify) {
|
|
6266
|
-
return
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6460
|
+
return {
|
|
6461
|
+
fromLink: true,
|
|
6462
|
+
sources: [
|
|
6463
|
+
resultsFromCache(queryInfo.getDiff()),
|
|
6464
|
+
resultsFromLink(),
|
|
6465
|
+
],
|
|
6466
|
+
};
|
|
6270
6467
|
}
|
|
6271
|
-
return [resultsFromLink()];
|
|
6468
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6272
6469
|
case "standby":
|
|
6273
|
-
return [];
|
|
6470
|
+
return { fromLink: false, sources: [] };
|
|
6274
6471
|
}
|
|
6275
6472
|
};
|
|
6276
6473
|
QueryManager.prototype.getQuery = function (queryId) {
|
|
@@ -6577,8 +6774,8 @@ function useApolloClient(override) {
|
|
|
6577
6774
|
|
|
6578
6775
|
var didWarnUncachedGetSnapshot = false;
|
|
6579
6776
|
var uSESKey = "useSyncExternalStore";
|
|
6580
|
-
var realHook = React__namespace[uSESKey];
|
|
6581
|
-
var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6777
|
+
var realHook$1 = React__namespace[uSESKey];
|
|
6778
|
+
var useSyncExternalStore = realHook$1 || (function (subscribe, getSnapshot, getServerSnapshot) {
|
|
6582
6779
|
var value = getSnapshot();
|
|
6583
6780
|
if (__DEV__ &&
|
|
6584
6781
|
!didWarnUncachedGetSnapshot &&
|
|
@@ -6736,8 +6933,6 @@ var InternalState = (function () {
|
|
|
6736
6933
|
function InternalState(client, query, previous) {
|
|
6737
6934
|
this.client = client;
|
|
6738
6935
|
this.query = query;
|
|
6739
|
-
this.asyncResolveFns = new Set();
|
|
6740
|
-
this.optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)();
|
|
6741
6936
|
this.ssrDisabledResult = maybeDeepFreeze({
|
|
6742
6937
|
loading: true,
|
|
6743
6938
|
data: void 0,
|
|
@@ -6761,20 +6956,30 @@ var InternalState = (function () {
|
|
|
6761
6956
|
InternalState.prototype.forceUpdate = function () {
|
|
6762
6957
|
__DEV__ && tsInvariant.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
|
|
6763
6958
|
};
|
|
6764
|
-
InternalState.prototype.
|
|
6959
|
+
InternalState.prototype.executeQuery = function (options) {
|
|
6765
6960
|
var _this = this;
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6961
|
+
var _a;
|
|
6962
|
+
if (options.query) {
|
|
6963
|
+
Object.assign(this, { query: options.query });
|
|
6964
|
+
}
|
|
6965
|
+
this.watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6966
|
+
var concast = this.observable.reobserveAsConcast(this.getObsQueryOptions());
|
|
6967
|
+
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6968
|
+
this.result = void 0;
|
|
6969
|
+
this.forceUpdate();
|
|
6970
|
+
return new Promise(function (resolve) {
|
|
6971
|
+
var result;
|
|
6972
|
+
concast.subscribe({
|
|
6973
|
+
next: function (value) {
|
|
6974
|
+
result = value;
|
|
6975
|
+
},
|
|
6976
|
+
error: function () {
|
|
6977
|
+
resolve(_this.toQueryResult(_this.observable.getCurrentResult()));
|
|
6978
|
+
},
|
|
6979
|
+
complete: function () {
|
|
6980
|
+
resolve(_this.toQueryResult(result));
|
|
6981
|
+
}
|
|
6982
|
+
});
|
|
6778
6983
|
});
|
|
6779
6984
|
};
|
|
6780
6985
|
InternalState.prototype.useQuery = function (options) {
|
|
@@ -6792,7 +6997,7 @@ var InternalState = (function () {
|
|
|
6792
6997
|
if (previousResult &&
|
|
6793
6998
|
previousResult.loading === result.loading &&
|
|
6794
6999
|
previousResult.networkStatus === result.networkStatus &&
|
|
6795
|
-
|
|
7000
|
+
equal.equal(previousResult.data, result.data)) {
|
|
6796
7001
|
return;
|
|
6797
7002
|
}
|
|
6798
7003
|
_this.setResult(result);
|
|
@@ -6813,7 +7018,7 @@ var InternalState = (function () {
|
|
|
6813
7018
|
var previousResult = _this.result;
|
|
6814
7019
|
if (!previousResult ||
|
|
6815
7020
|
(previousResult && previousResult.loading) ||
|
|
6816
|
-
!
|
|
7021
|
+
!equal.equal(error, previousResult.error)) {
|
|
6817
7022
|
_this.setResult({
|
|
6818
7023
|
data: (previousResult && previousResult.data),
|
|
6819
7024
|
error: error,
|
|
@@ -6830,22 +7035,15 @@ var InternalState = (function () {
|
|
|
6830
7035
|
this.client.disableNetworkFetches,
|
|
6831
7036
|
]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
|
|
6832
7037
|
this.unsafeHandlePartialRefetch(result);
|
|
6833
|
-
|
|
6834
|
-
if (!queryResult.loading && this.asyncResolveFns.size) {
|
|
6835
|
-
this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
|
|
6836
|
-
this.asyncResolveFns.clear();
|
|
6837
|
-
}
|
|
6838
|
-
return queryResult;
|
|
7038
|
+
return this.toQueryResult(result);
|
|
6839
7039
|
};
|
|
6840
7040
|
InternalState.prototype.useOptions = function (options) {
|
|
6841
7041
|
var _a;
|
|
6842
7042
|
var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6843
7043
|
var currentWatchQueryOptions = this.watchQueryOptions;
|
|
6844
|
-
if (
|
|
6845
|
-
!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
7044
|
+
if (!equal.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
6846
7045
|
this.watchQueryOptions = watchQueryOptions;
|
|
6847
7046
|
if (currentWatchQueryOptions && this.observable) {
|
|
6848
|
-
this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
|
|
6849
7047
|
this.observable.reobserve(this.getObsQueryOptions());
|
|
6850
7048
|
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6851
7049
|
this.result = void 0;
|
|
@@ -7012,11 +7210,15 @@ var EAGER_METHODS = [
|
|
|
7012
7210
|
'subscribeToMore',
|
|
7013
7211
|
];
|
|
7014
7212
|
function useLazyQuery(query, options) {
|
|
7015
|
-
var _a
|
|
7016
|
-
var abortControllersRef = React.useRef(new Set());
|
|
7213
|
+
var _a;
|
|
7017
7214
|
var execOptionsRef = React.useRef();
|
|
7018
|
-
var
|
|
7019
|
-
var
|
|
7215
|
+
var optionsRef = React.useRef();
|
|
7216
|
+
var queryRef = React.useRef();
|
|
7217
|
+
var merged = mergeOptions(options, execOptionsRef.current || {});
|
|
7218
|
+
var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
|
|
7219
|
+
optionsRef.current = merged;
|
|
7220
|
+
queryRef.current = document;
|
|
7221
|
+
var internalState = useInternalState(useApolloClient(options && options.client), document);
|
|
7020
7222
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
7021
7223
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
7022
7224
|
internalState.getDefaultFetchPolicy();
|
|
@@ -7042,28 +7244,15 @@ function useLazyQuery(query, options) {
|
|
|
7042
7244
|
return eagerMethods;
|
|
7043
7245
|
}, []);
|
|
7044
7246
|
Object.assign(result, eagerMethods);
|
|
7045
|
-
React.useEffect(function () {
|
|
7046
|
-
return function () {
|
|
7047
|
-
abortControllersRef.current.forEach(function (controller) {
|
|
7048
|
-
controller.abort();
|
|
7049
|
-
});
|
|
7050
|
-
};
|
|
7051
|
-
}, []);
|
|
7052
7247
|
var execute = React.useCallback(function (executeOptions) {
|
|
7053
|
-
var controller = new AbortController();
|
|
7054
|
-
abortControllersRef.current.add(controller);
|
|
7055
7248
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
7056
7249
|
fetchPolicy: initialFetchPolicy,
|
|
7057
7250
|
};
|
|
7251
|
+
var options = mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
|
|
7058
7252
|
var promise = internalState
|
|
7059
|
-
.
|
|
7060
|
-
.then(function (queryResult) {
|
|
7061
|
-
|
|
7062
|
-
return Object.assign(queryResult, eagerMethods);
|
|
7063
|
-
});
|
|
7064
|
-
promise.catch(function () {
|
|
7065
|
-
abortControllersRef.current.delete(controller);
|
|
7066
|
-
});
|
|
7253
|
+
.executeQuery(tslib.__assign(tslib.__assign({}, options), { skip: false }))
|
|
7254
|
+
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
7255
|
+
promise.catch(function () { });
|
|
7067
7256
|
return promise;
|
|
7068
7257
|
}, []);
|
|
7069
7258
|
return [execute, result];
|
|
@@ -7119,7 +7308,7 @@ function useMutation(mutation, options) {
|
|
|
7119
7308
|
error: error,
|
|
7120
7309
|
client: client,
|
|
7121
7310
|
};
|
|
7122
|
-
if (ref.current.isMounted && !
|
|
7311
|
+
if (ref.current.isMounted && !equal.equal(ref.current.result, result_1)) {
|
|
7123
7312
|
setResult(ref.current.result = result_1);
|
|
7124
7313
|
}
|
|
7125
7314
|
}
|
|
@@ -7137,7 +7326,7 @@ function useMutation(mutation, options) {
|
|
|
7137
7326
|
called: true,
|
|
7138
7327
|
client: client,
|
|
7139
7328
|
};
|
|
7140
|
-
if (!
|
|
7329
|
+
if (!equal.equal(ref.current.result, result_2)) {
|
|
7141
7330
|
setResult(ref.current.result = result_2);
|
|
7142
7331
|
}
|
|
7143
7332
|
}
|
|
@@ -7227,7 +7416,7 @@ function useSubscription(subscription, options) {
|
|
|
7227
7416
|
subscription !== ref.current.subscription ||
|
|
7228
7417
|
(options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
|
|
7229
7418
|
!(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
|
|
7230
|
-
!
|
|
7419
|
+
!equal.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
|
|
7231
7420
|
canResetObservableRef.current) {
|
|
7232
7421
|
setResult({
|
|
7233
7422
|
loading: true,
|
|
@@ -7323,13 +7512,13 @@ function useFragment_experimental(options) {
|
|
|
7323
7512
|
var getSnapshot = function () {
|
|
7324
7513
|
var latestDiffToResult = diffToResult(latestDiff);
|
|
7325
7514
|
return resultRef.current &&
|
|
7326
|
-
|
|
7515
|
+
equal.equal(resultRef.current.data, latestDiffToResult.data)
|
|
7327
7516
|
? resultRef.current
|
|
7328
7517
|
: (resultRef.current = latestDiffToResult);
|
|
7329
7518
|
};
|
|
7330
7519
|
return useSyncExternalStore(function (forceUpdate) {
|
|
7331
7520
|
return cache.watch(tslib.__assign(tslib.__assign({}, diffOptions), { immediate: true, callback: function (diff) {
|
|
7332
|
-
if (!
|
|
7521
|
+
if (!equal.equal(diff, latestDiff)) {
|
|
7333
7522
|
resultRef.current = diffToResult((latestDiff = diff));
|
|
7334
7523
|
forceUpdate();
|
|
7335
7524
|
}
|
|
@@ -7349,7 +7538,7 @@ function diffToResult(diff) {
|
|
|
7349
7538
|
|
|
7350
7539
|
function useDeepMemo(memoFn, deps) {
|
|
7351
7540
|
var ref = React.useRef();
|
|
7352
|
-
if (!ref.current || !
|
|
7541
|
+
if (!ref.current || !equal.equal(ref.current.deps, deps)) {
|
|
7353
7542
|
ref.current = { value: memoFn(), deps: deps };
|
|
7354
7543
|
}
|
|
7355
7544
|
return ref.current.value;
|
|
@@ -7365,42 +7554,20 @@ function useStrictModeSafeCleanupEffect(cleanup) {
|
|
|
7365
7554
|
}, []);
|
|
7366
7555
|
}
|
|
7367
7556
|
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
function
|
|
7372
|
-
|
|
7373
|
-
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
fulfilledPromise.status = 'fulfilled';
|
|
7381
|
-
fulfilledPromise.value = value;
|
|
7557
|
+
var useKey = 'use';
|
|
7558
|
+
var realHook = React__default[useKey];
|
|
7559
|
+
var __use = realHook ||
|
|
7560
|
+
function __use(promise) {
|
|
7561
|
+
var statefulPromise = wrapPromiseWithState(promise);
|
|
7562
|
+
switch (statefulPromise.status) {
|
|
7563
|
+
case 'pending':
|
|
7564
|
+
throw statefulPromise;
|
|
7565
|
+
case 'rejected':
|
|
7566
|
+
throw statefulPromise.reason;
|
|
7567
|
+
case 'fulfilled':
|
|
7568
|
+
return statefulPromise.value;
|
|
7382
7569
|
}
|
|
7383
|
-
}
|
|
7384
|
-
if (pendingPromise.status === 'pending') {
|
|
7385
|
-
var rejectedPromise = pendingPromise;
|
|
7386
|
-
rejectedPromise.status = 'rejected';
|
|
7387
|
-
rejectedPromise.reason = reason;
|
|
7388
|
-
}
|
|
7389
|
-
});
|
|
7390
|
-
return promise;
|
|
7391
|
-
}
|
|
7392
|
-
|
|
7393
|
-
function __use(promise) {
|
|
7394
|
-
var statefulPromise = wrapPromiseWithState(promise);
|
|
7395
|
-
switch (statefulPromise.status) {
|
|
7396
|
-
case 'pending':
|
|
7397
|
-
throw statefulPromise;
|
|
7398
|
-
case 'rejected':
|
|
7399
|
-
throw statefulPromise.reason;
|
|
7400
|
-
case 'fulfilled':
|
|
7401
|
-
return statefulPromise.value;
|
|
7402
|
-
}
|
|
7403
|
-
}
|
|
7570
|
+
};
|
|
7404
7571
|
|
|
7405
7572
|
function useSuspenseCache(override) {
|
|
7406
7573
|
var context = React.useContext(getApolloContext());
|
|
@@ -7418,15 +7585,18 @@ function useSuspenseQuery_experimental(query, options) {
|
|
|
7418
7585
|
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7419
7586
|
var watchQueryOptions = useWatchQueryOptions({ query: query, options: options });
|
|
7420
7587
|
var _a = watchQueryOptions.returnPartialData, returnPartialData = _a === void 0 ? false : _a, variables = watchQueryOptions.variables;
|
|
7421
|
-
var _b = options.suspensePolicy, suspensePolicy = _b === void 0 ? 'always' : _b;
|
|
7588
|
+
var _b = options.suspensePolicy, suspensePolicy = _b === void 0 ? 'always' : _b, _c = options.queryKey, queryKey = _c === void 0 ? [] : _c;
|
|
7422
7589
|
var shouldSuspend = suspensePolicy === 'always' || !didPreviouslySuspend.current;
|
|
7423
|
-
var
|
|
7590
|
+
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
7591
|
+
var subscription = suspenseCache.getSubscription(cacheKey, function () {
|
|
7592
|
+
return client.watchQuery(watchQueryOptions);
|
|
7593
|
+
});
|
|
7424
7594
|
var dispose = useTrackedSubscriptions(subscription);
|
|
7425
7595
|
useStrictModeSafeCleanupEffect(dispose);
|
|
7426
7596
|
var result = useSyncExternalStore(subscription.listen, function () { return subscription.result; }, function () { return subscription.result; });
|
|
7427
7597
|
var previousVariables = React.useRef(variables);
|
|
7428
7598
|
var previousData = React.useRef(result.data);
|
|
7429
|
-
if (!
|
|
7599
|
+
if (!equal.equal(variables, previousVariables.current)) {
|
|
7430
7600
|
if (result.networkStatus !== exports.NetworkStatus.ready) {
|
|
7431
7601
|
result = tslib.__assign(tslib.__assign({}, result), { data: previousData.current, networkStatus: exports.NetworkStatus.setVariables });
|
|
7432
7602
|
}
|
|
@@ -7604,16 +7774,16 @@ var SuspenseCache = (function () {
|
|
|
7604
7774
|
this.subscriptions = new Map();
|
|
7605
7775
|
this.options = options;
|
|
7606
7776
|
}
|
|
7607
|
-
SuspenseCache.prototype.getSubscription = function (
|
|
7777
|
+
SuspenseCache.prototype.getSubscription = function (cacheKey, createObservable) {
|
|
7608
7778
|
var _this = this;
|
|
7609
|
-
var
|
|
7610
|
-
if (!this.subscriptions.has(
|
|
7611
|
-
this.subscriptions.set(
|
|
7779
|
+
var stableCacheKey = this.cacheKeys.lookupArray(cacheKey);
|
|
7780
|
+
if (!this.subscriptions.has(stableCacheKey)) {
|
|
7781
|
+
this.subscriptions.set(stableCacheKey, new QuerySubscription(createObservable(), {
|
|
7612
7782
|
autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
|
|
7613
|
-
onDispose: function () { return _this.subscriptions.delete(
|
|
7783
|
+
onDispose: function () { return _this.subscriptions.delete(stableCacheKey); },
|
|
7614
7784
|
}));
|
|
7615
7785
|
}
|
|
7616
|
-
return this.subscriptions.get(
|
|
7786
|
+
return this.subscriptions.get(stableCacheKey);
|
|
7617
7787
|
};
|
|
7618
7788
|
return SuspenseCache;
|
|
7619
7789
|
}());
|
|
@@ -7650,6 +7820,7 @@ exports.fromError = fromError;
|
|
|
7650
7820
|
exports.fromPromise = fromPromise;
|
|
7651
7821
|
exports.getApolloContext = getApolloContext;
|
|
7652
7822
|
exports.isApolloError = isApolloError;
|
|
7823
|
+
exports.isNetworkRequestSettled = isNetworkRequestSettled;
|
|
7653
7824
|
exports.isReference = isReference;
|
|
7654
7825
|
exports.makeReference = makeReference;
|
|
7655
7826
|
exports.makeVar = makeVar;
|