@apollo/client 3.8.0-beta.4 → 3.8.0-beta.6
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 +225 -175
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.js +4 -3
- package/core/LocalState.js +2 -2
- package/core/ObservableQuery.d.ts +2 -0
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +26 -9
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +2 -2
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +9 -9
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +42 -24
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +42 -24
- package/dev/dev.cjs +73 -80
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +73 -80
- package/invariantErrorCodes.js +72 -79
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/http.cjs +3 -3
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +3 -3
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/persisted-queries/persisted-queries.cjs +2 -2
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +1 -1
- package/package.json +16 -16
- package/react/cache/QueryReference.d.ts +9 -3
- package/react/cache/QueryReference.d.ts.map +1 -1
- package/react/cache/QueryReference.js +50 -20
- package/react/cache/QueryReference.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +2 -2
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js +2 -2
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/context.cjs +3 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +3 -3
- package/react/hoc/hoc-utils.js +1 -1
- package/react/hoc/hoc.cjs +2 -2
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +2 -2
- package/react/hoc/withApollo.js +1 -1
- package/react/hooks/hooks.cjs +174 -27
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +174 -27
- package/react/hooks/index.d.ts +2 -1
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +2 -1
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +16 -13
- package/react/hooks/useBackgroundQuery.d.ts.map +1 -1
- package/react/hooks/useBackgroundQuery.js +8 -44
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useReadQuery.d.ts +8 -0
- package/react/hooks/useReadQuery.d.ts.map +1 -0
- package/react/hooks/useReadQuery.js +42 -0
- package/react/hooks/useReadQuery.js.map +1 -0
- package/react/hooks/useSubscription.js +2 -2
- package/react/hooks/useSuspenseCache.js +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +2 -2
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +5 -6
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/parser.cjs +5 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +5 -5
- package/react/react.cjs +49 -20
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +49 -20
- package/react/types/types.d.ts +6 -0
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +1 -1
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +1 -1
- package/testing/core/mocking/mockLink.js +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/graphql/DocumentTransform.js +1 -1
- package/utilities/graphql/directives.js +4 -4
- package/utilities/graphql/fragments.js +3 -3
- package/utilities/graphql/getFromAST.js +8 -8
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/index.js.map +1 -1
- package/utilities/promises/decoration.d.ts.map +1 -1
- package/utilities/promises/decoration.js +1 -0
- package/utilities/promises/decoration.js.map +1 -1
- package/utilities/utilities.cjs +20 -19
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +20 -19
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var tslib = require('tslib');
|
|
|
6
6
|
var process$1 = require('ts-invariant/process');
|
|
7
7
|
var graphql = require('graphql');
|
|
8
8
|
var equal = require('@wry/equality');
|
|
9
|
-
var
|
|
9
|
+
var invariant$1 = require('ts-invariant');
|
|
10
10
|
var zenObservableTs = require('zen-observable-ts');
|
|
11
11
|
require('symbol-observable');
|
|
12
12
|
var optimism = require('optimism');
|
|
@@ -30,10 +30,11 @@ function _interopNamespace(e) {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
33
|
+
var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant$1);
|
|
33
34
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
35
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
35
36
|
|
|
36
|
-
var version = '3.8.0-beta.
|
|
37
|
+
var version = '3.8.0-beta.6';
|
|
37
38
|
|
|
38
39
|
function maybe(thunk) {
|
|
39
40
|
try {
|
|
@@ -78,20 +79,20 @@ var invariant = Object.assign(function invariant(condition, message) {
|
|
|
78
79
|
args[_i - 2] = arguments[_i];
|
|
79
80
|
}
|
|
80
81
|
if (!condition) {
|
|
81
|
-
|
|
82
|
+
invariant$1.invariant(condition, getErrorMsg(message, args));
|
|
82
83
|
}
|
|
83
84
|
}, {
|
|
84
|
-
debug: wrap(
|
|
85
|
-
log: wrap(
|
|
86
|
-
warn: wrap(
|
|
87
|
-
error: wrap(
|
|
85
|
+
debug: wrap(invariant$1.invariant.debug),
|
|
86
|
+
log: wrap(invariant$1.invariant.log),
|
|
87
|
+
warn: wrap(invariant$1.invariant.warn),
|
|
88
|
+
error: wrap(invariant$1.invariant.error),
|
|
88
89
|
});
|
|
89
90
|
function newInvariantError(message) {
|
|
90
91
|
var optionalParams = [];
|
|
91
92
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
92
93
|
optionalParams[_i - 1] = arguments[_i];
|
|
93
94
|
}
|
|
94
|
-
return new
|
|
95
|
+
return new invariant$1.InvariantError(getErrorMsg(message, optionalParams));
|
|
95
96
|
}
|
|
96
97
|
var ApolloErrorMessageHandler = Symbol.for('ApolloErrorMessageHandler_' + version);
|
|
97
98
|
function getErrorMsg(message, messageArgs) {
|
|
@@ -131,7 +132,7 @@ function shouldInclude(_a, variables) {
|
|
|
131
132
|
var evaledValue = false;
|
|
132
133
|
if (ifArgument.value.kind === 'Variable') {
|
|
133
134
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
134
|
-
invariant(evaledValue !== void 0,
|
|
135
|
+
invariant(evaledValue !== void 0, 65, directive.name.value);
|
|
135
136
|
}
|
|
136
137
|
else {
|
|
137
138
|
evaledValue = ifArgument.value.value;
|
|
@@ -167,12 +168,12 @@ function getInclusionDirectives(directives) {
|
|
|
167
168
|
return;
|
|
168
169
|
var directiveArguments = directive.arguments;
|
|
169
170
|
var directiveName = directive.name.value;
|
|
170
|
-
invariant(directiveArguments && directiveArguments.length === 1,
|
|
171
|
+
invariant(directiveArguments && directiveArguments.length === 1, 66, directiveName);
|
|
171
172
|
var ifArgument = directiveArguments[0];
|
|
172
|
-
invariant(ifArgument.name && ifArgument.name.value === 'if',
|
|
173
|
+
invariant(ifArgument.name && ifArgument.name.value === 'if', 67, directiveName);
|
|
173
174
|
var ifValue = ifArgument.value;
|
|
174
175
|
invariant(ifValue &&
|
|
175
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
176
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 68, directiveName);
|
|
176
177
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
177
178
|
});
|
|
178
179
|
}
|
|
@@ -199,7 +200,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
199
200
|
document.definitions.forEach(function (definition) {
|
|
200
201
|
if (definition.kind === 'OperationDefinition') {
|
|
201
202
|
throw newInvariantError(
|
|
202
|
-
|
|
203
|
+
69,
|
|
203
204
|
definition.operation,
|
|
204
205
|
definition.name ? " named '".concat(definition.name.value, "'") : ''
|
|
205
206
|
);
|
|
@@ -209,7 +210,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
209
210
|
}
|
|
210
211
|
});
|
|
211
212
|
if (typeof actualFragmentName === 'undefined') {
|
|
212
|
-
invariant(fragments.length === 1,
|
|
213
|
+
invariant(fragments.length === 1, 70, fragments.length);
|
|
213
214
|
actualFragmentName = fragments[0].name.value;
|
|
214
215
|
}
|
|
215
216
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -250,7 +251,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
250
251
|
return fragmentMap(fragmentName);
|
|
251
252
|
}
|
|
252
253
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
253
|
-
invariant(fragment,
|
|
254
|
+
invariant(fragment, 71, fragmentName);
|
|
254
255
|
return fragment || null;
|
|
255
256
|
}
|
|
256
257
|
default:
|
|
@@ -328,7 +329,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
328
329
|
argObj[name.value] = null;
|
|
329
330
|
}
|
|
330
331
|
else {
|
|
331
|
-
throw newInvariantError(
|
|
332
|
+
throw newInvariantError(80, name.value, value.kind);
|
|
332
333
|
}
|
|
333
334
|
}
|
|
334
335
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -473,16 +474,16 @@ function isInlineFragment(selection) {
|
|
|
473
474
|
}
|
|
474
475
|
|
|
475
476
|
function checkDocument(doc) {
|
|
476
|
-
invariant(doc && doc.kind === 'Document',
|
|
477
|
+
invariant(doc && doc.kind === 'Document', 72);
|
|
477
478
|
var operations = doc.definitions
|
|
478
479
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
479
480
|
.map(function (definition) {
|
|
480
481
|
if (definition.kind !== 'OperationDefinition') {
|
|
481
|
-
throw newInvariantError(
|
|
482
|
+
throw newInvariantError(73, definition.kind);
|
|
482
483
|
}
|
|
483
484
|
return definition;
|
|
484
485
|
});
|
|
485
|
-
invariant(operations.length <= 1,
|
|
486
|
+
invariant(operations.length <= 1, 74, operations.length);
|
|
486
487
|
return doc;
|
|
487
488
|
}
|
|
488
489
|
function getOperationDefinition(doc) {
|
|
@@ -505,14 +506,14 @@ function getFragmentDefinitions(doc) {
|
|
|
505
506
|
}
|
|
506
507
|
function getQueryDefinition(doc) {
|
|
507
508
|
var queryDef = getOperationDefinition(doc);
|
|
508
|
-
invariant(queryDef && queryDef.operation === 'query',
|
|
509
|
+
invariant(queryDef && queryDef.operation === 'query', 75);
|
|
509
510
|
return queryDef;
|
|
510
511
|
}
|
|
511
512
|
function getFragmentDefinition(doc) {
|
|
512
|
-
invariant(doc.kind === 'Document',
|
|
513
|
-
invariant(doc.definitions.length <= 1,
|
|
513
|
+
invariant(doc.kind === 'Document', 76);
|
|
514
|
+
invariant(doc.definitions.length <= 1, 77);
|
|
514
515
|
var fragmentDef = doc.definitions[0];
|
|
515
|
-
invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
516
|
+
invariant(fragmentDef.kind === 'FragmentDefinition', 78);
|
|
516
517
|
return fragmentDef;
|
|
517
518
|
}
|
|
518
519
|
function getMainDefinition(queryDoc) {
|
|
@@ -535,7 +536,7 @@ function getMainDefinition(queryDoc) {
|
|
|
535
536
|
if (fragmentDefinition) {
|
|
536
537
|
return fragmentDefinition;
|
|
537
538
|
}
|
|
538
|
-
throw newInvariantError(
|
|
539
|
+
throw newInvariantError(79);
|
|
539
540
|
}
|
|
540
541
|
function getDefaultValues(definition) {
|
|
541
542
|
var defaultValues = Object.create(null);
|
|
@@ -607,7 +608,7 @@ var DocumentTransform = (function () {
|
|
|
607
608
|
return;
|
|
608
609
|
var cacheKeys = this.getCacheKey(document);
|
|
609
610
|
if (cacheKeys) {
|
|
610
|
-
invariant(Array.isArray(cacheKeys),
|
|
611
|
+
invariant(Array.isArray(cacheKeys), 64);
|
|
611
612
|
return this.stableCacheKeys.lookupArray(cacheKeys);
|
|
612
613
|
}
|
|
613
614
|
};
|
|
@@ -700,7 +701,7 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
700
701
|
return getInUseByFragmentName(ancestor.name.value);
|
|
701
702
|
}
|
|
702
703
|
}
|
|
703
|
-
__DEV__ && invariant.error(
|
|
704
|
+
__DEV__ && invariant.error(81);
|
|
704
705
|
return null;
|
|
705
706
|
};
|
|
706
707
|
var operationCount = 0;
|
|
@@ -977,6 +978,7 @@ function createFulfilledPromise(value) {
|
|
|
977
978
|
}
|
|
978
979
|
function createRejectedPromise(reason) {
|
|
979
980
|
var promise = Promise.reject(reason);
|
|
981
|
+
promise.catch(function () { });
|
|
980
982
|
promise.status = 'rejected';
|
|
981
983
|
promise.reason = reason;
|
|
982
984
|
return promise;
|
|
@@ -1377,7 +1379,7 @@ function toPromise(observable) {
|
|
|
1377
1379
|
observable.subscribe({
|
|
1378
1380
|
next: function (data) {
|
|
1379
1381
|
if (completed) {
|
|
1380
|
-
__DEV__ && invariant.warn(
|
|
1382
|
+
__DEV__ && invariant.warn(40);
|
|
1381
1383
|
}
|
|
1382
1384
|
else {
|
|
1383
1385
|
completed = true;
|
|
@@ -1420,7 +1422,7 @@ function validateOperation(operation) {
|
|
|
1420
1422
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1421
1423
|
var key = _a[_i];
|
|
1422
1424
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1423
|
-
throw newInvariantError(
|
|
1425
|
+
throw newInvariantError(41, key);
|
|
1424
1426
|
}
|
|
1425
1427
|
}
|
|
1426
1428
|
return operation;
|
|
@@ -1527,7 +1529,7 @@ var ApolloLink = (function () {
|
|
|
1527
1529
|
ApolloLink.concat = function (first, second) {
|
|
1528
1530
|
var firstLink = toLink(first);
|
|
1529
1531
|
if (isTerminating(firstLink)) {
|
|
1530
|
-
__DEV__ && invariant.warn(
|
|
1532
|
+
__DEV__ && invariant.warn(33, firstLink);
|
|
1531
1533
|
return firstLink;
|
|
1532
1534
|
}
|
|
1533
1535
|
var nextLink = toLink(second);
|
|
@@ -1551,7 +1553,7 @@ var ApolloLink = (function () {
|
|
|
1551
1553
|
return ApolloLink.concat(this, next);
|
|
1552
1554
|
};
|
|
1553
1555
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1554
|
-
throw newInvariantError(
|
|
1556
|
+
throw newInvariantError(34);
|
|
1555
1557
|
};
|
|
1556
1558
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1557
1559
|
if (observer && observer.error) {
|
|
@@ -1926,7 +1928,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1926
1928
|
serialized = JSON.stringify(p);
|
|
1927
1929
|
}
|
|
1928
1930
|
catch (e) {
|
|
1929
|
-
var parseError = newInvariantError(
|
|
1931
|
+
var parseError = newInvariantError(37, label, e.message);
|
|
1930
1932
|
parseError.parseError = e;
|
|
1931
1933
|
throw parseError;
|
|
1932
1934
|
}
|
|
@@ -2009,7 +2011,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
|
|
|
2009
2011
|
|
|
2010
2012
|
var checkFetcher = function (fetcher) {
|
|
2011
2013
|
if (!fetcher && typeof fetch === 'undefined') {
|
|
2012
|
-
throw newInvariantError(
|
|
2014
|
+
throw newInvariantError(35);
|
|
2013
2015
|
}
|
|
2014
2016
|
};
|
|
2015
2017
|
|
|
@@ -2144,7 +2146,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
2144
2146
|
options.headers = options.headers || {};
|
|
2145
2147
|
var acceptHeader = "multipart/mixed;";
|
|
2146
2148
|
if (isSubscription && hasDefer) {
|
|
2147
|
-
__DEV__ && invariant.warn(
|
|
2149
|
+
__DEV__ && invariant.warn(36);
|
|
2148
2150
|
}
|
|
2149
2151
|
if (isSubscription) {
|
|
2150
2152
|
acceptHeader += 'boundary=graphql;subscriptionSpec=1.0,application/json';
|
|
@@ -4622,6 +4624,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4622
4624
|
_this.subscriptions = new Set();
|
|
4623
4625
|
_this.queryInfo = queryInfo;
|
|
4624
4626
|
_this.queryManager = queryManager;
|
|
4627
|
+
_this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);
|
|
4625
4628
|
_this.isTornDown = false;
|
|
4626
4629
|
var _b = queryManager.defaultOptions.watchQuery, _c = _b === void 0 ? {} : _b, _d = _c.fetchPolicy, defaultFetchPolicy = _d === void 0 ? "cache-first" : _d;
|
|
4627
4630
|
var _e = options.fetchPolicy, fetchPolicy = _e === void 0 ? defaultFetchPolicy : _e, _f = options.initialFetchPolicy, initialFetchPolicy = _f === void 0 ? (fetchPolicy === "standby" ? defaultFetchPolicy : fetchPolicy) : _f;
|
|
@@ -4672,10 +4675,11 @@ var ObservableQuery = (function (_super) {
|
|
|
4672
4675
|
exports.NetworkStatus.ready;
|
|
4673
4676
|
var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
|
|
4674
4677
|
var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
|
|
4675
|
-
if (fetchPolicy
|
|
4676
|
-
fetchPolicy === 'no-cache' ||
|
|
4677
|
-
fetchPolicy === 'standby' ||
|
|
4678
|
+
if (skipCacheDataFor(fetchPolicy) ||
|
|
4678
4679
|
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) ;
|
|
4680
|
+
else if (this.waitForOwnResult) {
|
|
4681
|
+
this.queryInfo['updateWatch']();
|
|
4682
|
+
}
|
|
4679
4683
|
else {
|
|
4680
4684
|
var diff = this.queryInfo.getDiff();
|
|
4681
4685
|
if (diff.complete || this.options.returnPartialData) {
|
|
@@ -4762,7 +4766,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4762
4766
|
var vars = queryDef.variableDefinitions;
|
|
4763
4767
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
4764
4768
|
__DEV__ && invariant.warn(
|
|
4765
|
-
|
|
4769
|
+
18,
|
|
4766
4770
|
variables,
|
|
4767
4771
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
4768
4772
|
);
|
|
@@ -4853,7 +4857,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4853
4857
|
options.onError(err);
|
|
4854
4858
|
return;
|
|
4855
4859
|
}
|
|
4856
|
-
__DEV__ && invariant.error(
|
|
4860
|
+
__DEV__ && invariant.error(19, err);
|
|
4857
4861
|
},
|
|
4858
4862
|
});
|
|
4859
4863
|
this.subscriptions.add(subscription);
|
|
@@ -4866,6 +4870,10 @@ var ObservableQuery = (function (_super) {
|
|
|
4866
4870
|
ObservableQuery.prototype.setOptions = function (newOptions) {
|
|
4867
4871
|
return this.reobserve(newOptions);
|
|
4868
4872
|
};
|
|
4873
|
+
ObservableQuery.prototype.silentSetOptions = function (newOptions) {
|
|
4874
|
+
var mergedOptions = compact(this.options, newOptions || {});
|
|
4875
|
+
assign(this.options, mergedOptions);
|
|
4876
|
+
};
|
|
4869
4877
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
4870
4878
|
if (equal.equal(this.variables, variables)) {
|
|
4871
4879
|
return this.observers.size
|
|
@@ -4951,7 +4959,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4951
4959
|
pollingInfo.interval === pollInterval) {
|
|
4952
4960
|
return;
|
|
4953
4961
|
}
|
|
4954
|
-
invariant(pollInterval,
|
|
4962
|
+
invariant(pollInterval, 20);
|
|
4955
4963
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
4956
4964
|
info.interval = pollInterval;
|
|
4957
4965
|
var maybeFetch = function () {
|
|
@@ -5013,13 +5021,21 @@ var ObservableQuery = (function (_super) {
|
|
|
5013
5021
|
}
|
|
5014
5022
|
}
|
|
5015
5023
|
var fetchOptions = query === options.query ? options : tslib.__assign(tslib.__assign({}, options), { query: query });
|
|
5016
|
-
|
|
5024
|
+
this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(fetchOptions.fetchPolicy));
|
|
5025
|
+
var finishWaitingForOwnResult = function () {
|
|
5026
|
+
if (_this.concast === concast) {
|
|
5027
|
+
_this.waitForOwnResult = false;
|
|
5028
|
+
}
|
|
5029
|
+
};
|
|
5030
|
+
var variables = fetchOptions.variables && tslib.__assign({}, fetchOptions.variables);
|
|
5017
5031
|
var _a = this.fetch(fetchOptions, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
5018
5032
|
var observer = {
|
|
5019
5033
|
next: function (result) {
|
|
5034
|
+
finishWaitingForOwnResult();
|
|
5020
5035
|
_this.reportResult(result, variables);
|
|
5021
5036
|
},
|
|
5022
5037
|
error: function (error) {
|
|
5038
|
+
finishWaitingForOwnResult();
|
|
5023
5039
|
_this.reportError(error, variables);
|
|
5024
5040
|
},
|
|
5025
5041
|
};
|
|
@@ -5096,13 +5112,16 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
5096
5112
|
return obsQuery.reobserve();
|
|
5097
5113
|
}
|
|
5098
5114
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
5099
|
-
__DEV__ && invariant.error(
|
|
5115
|
+
__DEV__ && invariant.error(21, error.message, error.stack);
|
|
5100
5116
|
}
|
|
5101
5117
|
function logMissingFieldErrors(missing) {
|
|
5102
5118
|
if (__DEV__ && missing) {
|
|
5103
|
-
__DEV__ && invariant.debug(
|
|
5119
|
+
__DEV__ && invariant.debug(22, missing);
|
|
5104
5120
|
}
|
|
5105
5121
|
}
|
|
5122
|
+
function skipCacheDataFor(fetchPolicy) {
|
|
5123
|
+
return fetchPolicy === "network-only" || fetchPolicy === "no-cache" || fetchPolicy === "standby";
|
|
5124
|
+
}
|
|
5106
5125
|
|
|
5107
5126
|
var LocalState = (function () {
|
|
5108
5127
|
function LocalState(_a) {
|
|
@@ -5279,7 +5298,7 @@ var LocalState = (function () {
|
|
|
5279
5298
|
}
|
|
5280
5299
|
else {
|
|
5281
5300
|
fragment = fragmentMap[selection.name.value];
|
|
5282
|
-
invariant(fragment,
|
|
5301
|
+
invariant(fragment, 16, selection.name.value);
|
|
5283
5302
|
}
|
|
5284
5303
|
if (fragment && fragment.typeCondition) {
|
|
5285
5304
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -5392,7 +5411,7 @@ var LocalState = (function () {
|
|
|
5392
5411
|
},
|
|
5393
5412
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
5394
5413
|
var fragment = fragmentMap[spread.name.value];
|
|
5395
|
-
invariant(fragment,
|
|
5414
|
+
invariant(fragment, 17, spread.name.value);
|
|
5396
5415
|
var fragmentSelections = collectByDefinition(fragment);
|
|
5397
5416
|
if (fragmentSelections.size > 0) {
|
|
5398
5417
|
ancestors.forEach(function (node) {
|
|
@@ -5729,7 +5748,7 @@ var QueryManager = (function () {
|
|
|
5729
5748
|
this.queries.forEach(function (_info, queryId) {
|
|
5730
5749
|
_this.stopQueryNoBroadcast(queryId);
|
|
5731
5750
|
});
|
|
5732
|
-
this.cancelPendingFetches(newInvariantError(
|
|
5751
|
+
this.cancelPendingFetches(newInvariantError(23));
|
|
5733
5752
|
};
|
|
5734
5753
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
5735
5754
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -5743,9 +5762,9 @@ var QueryManager = (function () {
|
|
|
5743
5762
|
return tslib.__generator(this, function (_h) {
|
|
5744
5763
|
switch (_h.label) {
|
|
5745
5764
|
case 0:
|
|
5746
|
-
invariant(mutation,
|
|
5765
|
+
invariant(mutation, 24);
|
|
5747
5766
|
invariant(fetchPolicy === 'network-only' ||
|
|
5748
|
-
fetchPolicy === 'no-cache',
|
|
5767
|
+
fetchPolicy === 'no-cache', 25);
|
|
5749
5768
|
mutationId = this.generateMutationId();
|
|
5750
5769
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
5751
5770
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -6063,10 +6082,10 @@ var QueryManager = (function () {
|
|
|
6063
6082
|
QueryManager.prototype.query = function (options, queryId) {
|
|
6064
6083
|
var _this = this;
|
|
6065
6084
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
6066
|
-
invariant(options.query,
|
|
6067
|
-
invariant(options.query.kind === 'Document',
|
|
6068
|
-
invariant(!options.returnPartialData,
|
|
6069
|
-
invariant(!options.pollInterval,
|
|
6085
|
+
invariant(options.query, 26);
|
|
6086
|
+
invariant(options.query.kind === 'Document', 27);
|
|
6087
|
+
invariant(!options.returnPartialData, 28);
|
|
6088
|
+
invariant(!options.pollInterval, 29);
|
|
6070
6089
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
6071
6090
|
};
|
|
6072
6091
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -6091,7 +6110,7 @@ var QueryManager = (function () {
|
|
|
6091
6110
|
if (options === void 0) { options = {
|
|
6092
6111
|
discardWatches: true,
|
|
6093
6112
|
}; }
|
|
6094
|
-
this.cancelPendingFetches(newInvariantError(
|
|
6113
|
+
this.cancelPendingFetches(newInvariantError(30));
|
|
6095
6114
|
this.queries.forEach(function (queryInfo) {
|
|
6096
6115
|
if (queryInfo.observableQuery) {
|
|
6097
6116
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -6167,7 +6186,7 @@ var QueryManager = (function () {
|
|
|
6167
6186
|
if (__DEV__ && queryNamesAndDocs.size) {
|
|
6168
6187
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
6169
6188
|
if (!included) {
|
|
6170
|
-
__DEV__ && invariant.warn(typeof nameOrDoc === "string" ?
|
|
6189
|
+
__DEV__ && invariant.warn(typeof nameOrDoc === "string" ? 31 : 32, nameOrDoc);
|
|
6171
6190
|
}
|
|
6172
6191
|
});
|
|
6173
6192
|
}
|
|
@@ -6629,7 +6648,8 @@ var ApolloClient = (function () {
|
|
|
6629
6648
|
}
|
|
6630
6649
|
}
|
|
6631
6650
|
if (url) {
|
|
6632
|
-
__DEV__ && invariant.log(
|
|
6651
|
+
__DEV__ && invariant.log("Download the Apollo DevTools for a better development " +
|
|
6652
|
+
"experience: %s", url);
|
|
6633
6653
|
}
|
|
6634
6654
|
}
|
|
6635
6655
|
}
|
|
@@ -6692,7 +6712,7 @@ var ApolloClient = (function () {
|
|
|
6692
6712
|
if (this.defaultOptions.query) {
|
|
6693
6713
|
options = mergeOptions(this.defaultOptions.query, options);
|
|
6694
6714
|
}
|
|
6695
|
-
invariant(options.fetchPolicy !== 'cache-and-network',
|
|
6715
|
+
invariant(options.fetchPolicy !== 'cache-and-network', 14);
|
|
6696
6716
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
6697
6717
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
6698
6718
|
}
|
|
@@ -6781,7 +6801,7 @@ var ApolloClient = (function () {
|
|
|
6781
6801
|
result.queries = queries;
|
|
6782
6802
|
result.results = results;
|
|
6783
6803
|
result.catch(function (error) {
|
|
6784
|
-
__DEV__ && invariant.debug(
|
|
6804
|
+
__DEV__ && invariant.debug(15, error);
|
|
6785
6805
|
});
|
|
6786
6806
|
return result;
|
|
6787
6807
|
};
|
|
@@ -6817,7 +6837,7 @@ var contextKey = canUseSymbol
|
|
|
6817
6837
|
? Symbol.for('__APOLLO_CONTEXT__')
|
|
6818
6838
|
: '__APOLLO_CONTEXT__';
|
|
6819
6839
|
function getApolloContext() {
|
|
6820
|
-
invariant('createContext' in React__namespace,
|
|
6840
|
+
invariant('createContext' in React__namespace, 43);
|
|
6821
6841
|
var contextStorage = global$1[contextKey] || (global$1[contextKey] = Object.create(null));
|
|
6822
6842
|
return contextStorage[React__namespace.version] || (contextStorage[React__namespace.version] = Object.assign(React__namespace.createContext({}), { displayName: 'ApolloContext' }));
|
|
6823
6843
|
}
|
|
@@ -6826,7 +6846,7 @@ var resetApolloContext = getApolloContext;
|
|
|
6826
6846
|
var ApolloConsumer = function (props) {
|
|
6827
6847
|
var ApolloContext = getApolloContext();
|
|
6828
6848
|
return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
6829
|
-
invariant(context && context.client,
|
|
6849
|
+
invariant(context && context.client, 42);
|
|
6830
6850
|
return props.children(context.client);
|
|
6831
6851
|
}));
|
|
6832
6852
|
};
|
|
@@ -6838,14 +6858,14 @@ var ApolloProvider = function (_a) {
|
|
|
6838
6858
|
var context = React__namespace.useMemo(function () {
|
|
6839
6859
|
return tslib.__assign(tslib.__assign({}, parentContext), { client: client || parentContext.client, suspenseCache: suspenseCache || parentContext.suspenseCache });
|
|
6840
6860
|
}, [parentContext, client, suspenseCache]);
|
|
6841
|
-
invariant(context.client,
|
|
6861
|
+
invariant(context.client, 44);
|
|
6842
6862
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
6843
6863
|
};
|
|
6844
6864
|
|
|
6845
6865
|
function useApolloClient(override) {
|
|
6846
6866
|
var context = React.useContext(getApolloContext());
|
|
6847
6867
|
var client = override || context.client;
|
|
6848
|
-
invariant(!!client,
|
|
6868
|
+
invariant(!!client, 47);
|
|
6849
6869
|
return client;
|
|
6850
6870
|
}
|
|
6851
6871
|
|
|
@@ -6858,7 +6878,7 @@ var useSyncExternalStore = realHook$1 || (function (subscribe, getSnapshot, getS
|
|
|
6858
6878
|
!didWarnUncachedGetSnapshot &&
|
|
6859
6879
|
value !== getSnapshot()) {
|
|
6860
6880
|
didWarnUncachedGetSnapshot = true;
|
|
6861
|
-
__DEV__ && invariant.error(
|
|
6881
|
+
__DEV__ && invariant.error(57);
|
|
6862
6882
|
}
|
|
6863
6883
|
var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
6864
6884
|
if (canUseLayoutEffect) {
|
|
@@ -6921,7 +6941,7 @@ function parser(document) {
|
|
|
6921
6941
|
if (cached)
|
|
6922
6942
|
return cached;
|
|
6923
6943
|
var variables, type, name;
|
|
6924
|
-
invariant(!!document && !!document.kind,
|
|
6944
|
+
invariant(!!document && !!document.kind, 58, document);
|
|
6925
6945
|
var fragments = [];
|
|
6926
6946
|
var queries = [];
|
|
6927
6947
|
var mutations = [];
|
|
@@ -6947,10 +6967,10 @@ function parser(document) {
|
|
|
6947
6967
|
}
|
|
6948
6968
|
}
|
|
6949
6969
|
invariant(!fragments.length ||
|
|
6950
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
6970
|
+
(queries.length || mutations.length || subscriptions.length), 59);
|
|
6951
6971
|
invariant(
|
|
6952
6972
|
queries.length + mutations.length + subscriptions.length <= 1,
|
|
6953
|
-
|
|
6973
|
+
60,
|
|
6954
6974
|
document,
|
|
6955
6975
|
queries.length,
|
|
6956
6976
|
subscriptions.length,
|
|
@@ -6964,7 +6984,7 @@ function parser(document) {
|
|
|
6964
6984
|
: mutations.length
|
|
6965
6985
|
? mutations
|
|
6966
6986
|
: subscriptions;
|
|
6967
|
-
invariant(definitions.length === 1,
|
|
6987
|
+
invariant(definitions.length === 1, 61, document, definitions.length);
|
|
6968
6988
|
var definition = definitions[0];
|
|
6969
6989
|
variables = definition.variableDefinitions || [];
|
|
6970
6990
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -6983,7 +7003,7 @@ function verifyDocumentType(document, type) {
|
|
|
6983
7003
|
var usedOperationName = operationName(operation.type);
|
|
6984
7004
|
invariant(
|
|
6985
7005
|
operation.type === type,
|
|
6986
|
-
|
|
7006
|
+
62,
|
|
6987
7007
|
requiredOperationName,
|
|
6988
7008
|
requiredOperationName,
|
|
6989
7009
|
usedOperationName
|
|
@@ -7034,7 +7054,7 @@ var InternalState = (function () {
|
|
|
7034
7054
|
}
|
|
7035
7055
|
}
|
|
7036
7056
|
InternalState.prototype.forceUpdate = function () {
|
|
7037
|
-
__DEV__ && invariant.warn(
|
|
7057
|
+
__DEV__ && invariant.warn(48);
|
|
7038
7058
|
};
|
|
7039
7059
|
InternalState.prototype.executeQuery = function (options) {
|
|
7040
7060
|
var _this = this;
|
|
@@ -7445,10 +7465,10 @@ function useSubscription(subscription, options) {
|
|
|
7445
7465
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
7446
7466
|
hasIssuedDeprecationWarningRef.current = true;
|
|
7447
7467
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
|
|
7448
|
-
__DEV__ && invariant.warn(options.onData ?
|
|
7468
|
+
__DEV__ && invariant.warn(options.onData ? 50 : 51);
|
|
7449
7469
|
}
|
|
7450
7470
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
|
|
7451
|
-
__DEV__ && invariant.warn(options.onComplete ?
|
|
7471
|
+
__DEV__ && invariant.warn(options.onComplete ? 52 : 53);
|
|
7452
7472
|
}
|
|
7453
7473
|
}
|
|
7454
7474
|
var _b = React.useState(function () {
|
|
@@ -7659,7 +7679,7 @@ var __use = realHook ||
|
|
|
7659
7679
|
function useSuspenseCache(override) {
|
|
7660
7680
|
var context = React.useContext(getApolloContext());
|
|
7661
7681
|
var suspenseCache = override || context.suspenseCache;
|
|
7662
|
-
invariant(suspenseCache,
|
|
7682
|
+
invariant(suspenseCache, 54);
|
|
7663
7683
|
return suspenseCache;
|
|
7664
7684
|
}
|
|
7665
7685
|
|
|
@@ -7674,11 +7694,10 @@ function useSuspenseQuery(query, options) {
|
|
|
7674
7694
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
7675
7695
|
return client.watchQuery(watchQueryOptions);
|
|
7676
7696
|
});
|
|
7677
|
-
var currentFetchPolicy = queryRef.watchQueryOptions.fetchPolicy;
|
|
7678
7697
|
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
7679
7698
|
var promise = promiseCache.get(queryRef.key);
|
|
7680
|
-
if (
|
|
7681
|
-
promise = queryRef.
|
|
7699
|
+
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
7700
|
+
promise = queryRef.applyOptions(watchQueryOptions);
|
|
7682
7701
|
promiseCache.set(queryRef.key, promise);
|
|
7683
7702
|
}
|
|
7684
7703
|
if (!promise) {
|
|
@@ -7702,7 +7721,7 @@ function useSuspenseQuery(query, options) {
|
|
|
7702
7721
|
error: error,
|
|
7703
7722
|
};
|
|
7704
7723
|
}, [queryRef.result]);
|
|
7705
|
-
var result =
|
|
7724
|
+
var result = fetchPolicy === 'standby' ? skipResult : __use(promise);
|
|
7706
7725
|
var fetchMore = React.useCallback(function (options) {
|
|
7707
7726
|
var promise = queryRef.fetchMore(options);
|
|
7708
7727
|
setPromiseCache(function (previousPromiseCache) {
|
|
@@ -7744,11 +7763,11 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
7744
7763
|
'no-cache',
|
|
7745
7764
|
'cache-and-network',
|
|
7746
7765
|
];
|
|
7747
|
-
invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
7766
|
+
invariant(supportedFetchPolicies.includes(fetchPolicy), 55, fetchPolicy);
|
|
7748
7767
|
}
|
|
7749
7768
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
7750
7769
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
7751
|
-
__DEV__ && invariant.warn(
|
|
7770
|
+
__DEV__ && invariant.warn(56);
|
|
7752
7771
|
}
|
|
7753
7772
|
}
|
|
7754
7773
|
function toApolloError(result) {
|
|
@@ -7781,86 +7800,17 @@ function useWatchQueryOptions(_a) {
|
|
|
7781
7800
|
}, [client, options, query]);
|
|
7782
7801
|
}
|
|
7783
7802
|
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
var currentFetchPolicy = queryRef.watchQueryOptions.fetchPolicy;
|
|
7796
|
-
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
7797
|
-
if (currentFetchPolicy === 'standby' && fetchPolicy !== currentFetchPolicy) {
|
|
7798
|
-
var promise = queryRef.reobserve({ fetchPolicy: fetchPolicy });
|
|
7799
|
-
promiseCache.set(queryRef.key, promise);
|
|
7800
|
-
}
|
|
7801
|
-
useTrackedQueryRefs(queryRef);
|
|
7802
|
-
var fetchMore = React.useCallback(function (options) {
|
|
7803
|
-
var promise = queryRef.fetchMore(options);
|
|
7804
|
-
setPromiseCache(function (promiseCache) {
|
|
7805
|
-
return new Map(promiseCache).set(queryRef.key, promise);
|
|
7806
|
-
});
|
|
7807
|
-
return promise;
|
|
7808
|
-
}, [queryRef]);
|
|
7809
|
-
var refetch = React.useCallback(function (variables) {
|
|
7810
|
-
var promise = queryRef.refetch(variables);
|
|
7811
|
-
setPromiseCache(function (promiseCache) {
|
|
7812
|
-
return new Map(promiseCache).set(queryRef.key, promise);
|
|
7813
|
-
});
|
|
7814
|
-
return promise;
|
|
7815
|
-
}, [queryRef]);
|
|
7816
|
-
queryRef.promiseCache = promiseCache;
|
|
7817
|
-
return React.useMemo(function () {
|
|
7818
|
-
return [
|
|
7819
|
-
queryRef,
|
|
7820
|
-
{
|
|
7821
|
-
fetchMore: fetchMore,
|
|
7822
|
-
refetch: refetch,
|
|
7823
|
-
},
|
|
7824
|
-
];
|
|
7825
|
-
}, [queryRef, fetchMore, refetch]);
|
|
7826
|
-
}
|
|
7827
|
-
function useReadQuery(queryRef) {
|
|
7828
|
-
var _a = React.useState(0), forceUpdate = _a[1];
|
|
7829
|
-
invariant(queryRef.promiseCache, 49);
|
|
7830
|
-
var skipResult = React.useMemo(function () {
|
|
7831
|
-
var error = toApolloError(queryRef.result);
|
|
7832
|
-
return {
|
|
7833
|
-
loading: false,
|
|
7834
|
-
data: queryRef.result.data,
|
|
7835
|
-
networkStatus: error ? exports.NetworkStatus.error : exports.NetworkStatus.ready,
|
|
7836
|
-
error: error,
|
|
7837
|
-
};
|
|
7838
|
-
}, [queryRef.result]);
|
|
7839
|
-
var promise = queryRef.promiseCache.get(queryRef.key);
|
|
7840
|
-
if (!promise) {
|
|
7841
|
-
promise = queryRef.promise;
|
|
7842
|
-
queryRef.promiseCache.set(queryRef.key, promise);
|
|
7843
|
-
}
|
|
7844
|
-
React.useEffect(function () {
|
|
7845
|
-
return queryRef.listen(function (promise) {
|
|
7846
|
-
queryRef.promiseCache.set(queryRef.key, promise);
|
|
7847
|
-
forceUpdate(function (prevState) { return prevState + 1; });
|
|
7848
|
-
});
|
|
7849
|
-
}, [queryRef]);
|
|
7850
|
-
var result = queryRef.watchQueryOptions.fetchPolicy === 'standby'
|
|
7851
|
-
? skipResult
|
|
7852
|
-
: __use(promise);
|
|
7853
|
-
return React.useMemo(function () {
|
|
7854
|
-
return {
|
|
7855
|
-
data: result.data,
|
|
7856
|
-
networkStatus: result.networkStatus,
|
|
7857
|
-
error: toApolloError(result),
|
|
7858
|
-
};
|
|
7859
|
-
}, [result]);
|
|
7860
|
-
}
|
|
7861
|
-
|
|
7862
|
-
var QueryReference = (function () {
|
|
7863
|
-
function QueryReference(observable, options) {
|
|
7803
|
+
var QUERY_REFERENCE_SYMBOL = Symbol();
|
|
7804
|
+
var OBSERVED_CHANGED_OPTIONS = [
|
|
7805
|
+
'canonizeResults',
|
|
7806
|
+
'context',
|
|
7807
|
+
'errorPolicy',
|
|
7808
|
+
'fetchPolicy',
|
|
7809
|
+
'refetchWritePolicy',
|
|
7810
|
+
'returnPartialData',
|
|
7811
|
+
];
|
|
7812
|
+
var InternalQueryReference = (function () {
|
|
7813
|
+
function InternalQueryReference(observable, options) {
|
|
7864
7814
|
var _this = this;
|
|
7865
7815
|
var _a;
|
|
7866
7816
|
this.listeners = new Set();
|
|
@@ -7895,14 +7845,33 @@ var QueryReference = (function () {
|
|
|
7895
7845
|
}
|
|
7896
7846
|
this.autoDisposeTimeoutId = setTimeout(this.dispose, (_a = options.autoDisposeTimeoutMs) !== null && _a !== void 0 ? _a : 30000);
|
|
7897
7847
|
}
|
|
7898
|
-
Object.defineProperty(
|
|
7848
|
+
Object.defineProperty(InternalQueryReference.prototype, "watchQueryOptions", {
|
|
7899
7849
|
get: function () {
|
|
7900
7850
|
return this.observable.options;
|
|
7901
7851
|
},
|
|
7902
7852
|
enumerable: false,
|
|
7903
7853
|
configurable: true
|
|
7904
7854
|
});
|
|
7905
|
-
|
|
7855
|
+
InternalQueryReference.prototype.didChangeOptions = function (watchQueryOptions) {
|
|
7856
|
+
var _this = this;
|
|
7857
|
+
return OBSERVED_CHANGED_OPTIONS.some(function (option) {
|
|
7858
|
+
return !equal.equal(_this.watchQueryOptions[option], watchQueryOptions[option]);
|
|
7859
|
+
});
|
|
7860
|
+
};
|
|
7861
|
+
InternalQueryReference.prototype.applyOptions = function (watchQueryOptions) {
|
|
7862
|
+
var currentFetchPolicy = this.watchQueryOptions.fetchPolicy;
|
|
7863
|
+
if (currentFetchPolicy === 'standby' &&
|
|
7864
|
+
currentFetchPolicy !== watchQueryOptions.fetchPolicy) {
|
|
7865
|
+
this.promise = this.observable.reobserve(watchQueryOptions);
|
|
7866
|
+
}
|
|
7867
|
+
else {
|
|
7868
|
+
this.observable.silentSetOptions(watchQueryOptions);
|
|
7869
|
+
this.result = tslib.__assign(tslib.__assign({}, this.result), this.observable.getCurrentResult());
|
|
7870
|
+
this.promise = createFulfilledPromise(this.result);
|
|
7871
|
+
}
|
|
7872
|
+
return this.promise;
|
|
7873
|
+
};
|
|
7874
|
+
InternalQueryReference.prototype.listen = function (listener) {
|
|
7906
7875
|
var _this = this;
|
|
7907
7876
|
clearTimeout(this.autoDisposeTimeoutId);
|
|
7908
7877
|
this.listeners.add(listener);
|
|
@@ -7910,29 +7879,29 @@ var QueryReference = (function () {
|
|
|
7910
7879
|
_this.listeners.delete(listener);
|
|
7911
7880
|
};
|
|
7912
7881
|
};
|
|
7913
|
-
|
|
7882
|
+
InternalQueryReference.prototype.refetch = function (variables) {
|
|
7914
7883
|
this.refetching = true;
|
|
7915
7884
|
var promise = this.observable.refetch(variables);
|
|
7916
7885
|
this.promise = promise;
|
|
7917
7886
|
return promise;
|
|
7918
7887
|
};
|
|
7919
|
-
|
|
7888
|
+
InternalQueryReference.prototype.fetchMore = function (options) {
|
|
7920
7889
|
var promise = this.observable.fetchMore(options);
|
|
7921
7890
|
this.promise = promise;
|
|
7922
7891
|
return promise;
|
|
7923
7892
|
};
|
|
7924
|
-
|
|
7893
|
+
InternalQueryReference.prototype.reobserve = function (watchQueryOptions) {
|
|
7925
7894
|
var promise = this.observable.reobserve(watchQueryOptions);
|
|
7926
7895
|
this.promise = promise;
|
|
7927
7896
|
return promise;
|
|
7928
7897
|
};
|
|
7929
|
-
|
|
7898
|
+
InternalQueryReference.prototype.dispose = function () {
|
|
7930
7899
|
this.subscription.unsubscribe();
|
|
7931
7900
|
this.onDispose();
|
|
7932
7901
|
};
|
|
7933
|
-
|
|
7902
|
+
InternalQueryReference.prototype.onDispose = function () {
|
|
7934
7903
|
};
|
|
7935
|
-
|
|
7904
|
+
InternalQueryReference.prototype.handleNext = function (result) {
|
|
7936
7905
|
if (!this.initialized || this.refetching) {
|
|
7937
7906
|
if (!isNetworkRequestSettled(result.networkStatus)) {
|
|
7938
7907
|
return;
|
|
@@ -7943,7 +7912,9 @@ var QueryReference = (function () {
|
|
|
7943
7912
|
this.initialized = true;
|
|
7944
7913
|
this.refetching = false;
|
|
7945
7914
|
this.result = result;
|
|
7946
|
-
this.resolve
|
|
7915
|
+
if (this.resolve) {
|
|
7916
|
+
this.resolve(result);
|
|
7917
|
+
}
|
|
7947
7918
|
return;
|
|
7948
7919
|
}
|
|
7949
7920
|
if (result.data === this.result.data) {
|
|
@@ -7953,27 +7924,106 @@ var QueryReference = (function () {
|
|
|
7953
7924
|
this.promise = createFulfilledPromise(result);
|
|
7954
7925
|
this.deliver(this.promise);
|
|
7955
7926
|
};
|
|
7956
|
-
|
|
7927
|
+
InternalQueryReference.prototype.handleError = function (error) {
|
|
7957
7928
|
var result = tslib.__assign(tslib.__assign({}, this.result), { error: error, networkStatus: exports.NetworkStatus.error });
|
|
7958
7929
|
this.result = result;
|
|
7959
7930
|
if (!this.initialized || this.refetching) {
|
|
7960
7931
|
this.initialized = true;
|
|
7961
7932
|
this.refetching = false;
|
|
7962
|
-
this.reject
|
|
7933
|
+
if (this.reject) {
|
|
7934
|
+
this.reject(error);
|
|
7935
|
+
}
|
|
7963
7936
|
return;
|
|
7964
7937
|
}
|
|
7965
|
-
this.
|
|
7966
|
-
this.promise = result.data
|
|
7967
|
-
? createFulfilledPromise(result)
|
|
7968
|
-
: createRejectedPromise(result);
|
|
7938
|
+
this.promise = createRejectedPromise(error);
|
|
7969
7939
|
this.deliver(this.promise);
|
|
7970
7940
|
};
|
|
7971
|
-
|
|
7941
|
+
InternalQueryReference.prototype.deliver = function (promise) {
|
|
7972
7942
|
this.listeners.forEach(function (listener) { return listener(promise); });
|
|
7973
7943
|
};
|
|
7974
|
-
return
|
|
7944
|
+
return InternalQueryReference;
|
|
7975
7945
|
}());
|
|
7976
7946
|
|
|
7947
|
+
function useBackgroundQuery(query, options) {
|
|
7948
|
+
if (options === void 0) { options = Object.create(null); }
|
|
7949
|
+
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7950
|
+
var client = useApolloClient(options.client);
|
|
7951
|
+
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
7952
|
+
var variables = watchQueryOptions.variables;
|
|
7953
|
+
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
7954
|
+
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
7955
|
+
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
7956
|
+
return client.watchQuery(watchQueryOptions);
|
|
7957
|
+
});
|
|
7958
|
+
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
7959
|
+
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
7960
|
+
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
7961
|
+
promiseCache.set(queryRef.key, promise);
|
|
7962
|
+
}
|
|
7963
|
+
useTrackedQueryRefs(queryRef);
|
|
7964
|
+
var fetchMore = React.useCallback(function (options) {
|
|
7965
|
+
var promise = queryRef.fetchMore(options);
|
|
7966
|
+
setPromiseCache(function (promiseCache) {
|
|
7967
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
7968
|
+
});
|
|
7969
|
+
return promise;
|
|
7970
|
+
}, [queryRef]);
|
|
7971
|
+
var refetch = React.useCallback(function (variables) {
|
|
7972
|
+
var promise = queryRef.refetch(variables);
|
|
7973
|
+
setPromiseCache(function (promiseCache) {
|
|
7974
|
+
return new Map(promiseCache).set(queryRef.key, promise);
|
|
7975
|
+
});
|
|
7976
|
+
return promise;
|
|
7977
|
+
}, [queryRef]);
|
|
7978
|
+
queryRef.promiseCache = promiseCache;
|
|
7979
|
+
return React.useMemo(function () {
|
|
7980
|
+
var _a;
|
|
7981
|
+
return [
|
|
7982
|
+
(_a = {}, _a[QUERY_REFERENCE_SYMBOL] = queryRef, _a),
|
|
7983
|
+
{
|
|
7984
|
+
fetchMore: fetchMore,
|
|
7985
|
+
refetch: refetch,
|
|
7986
|
+
},
|
|
7987
|
+
];
|
|
7988
|
+
}, [queryRef, fetchMore, refetch]);
|
|
7989
|
+
}
|
|
7990
|
+
|
|
7991
|
+
function useReadQuery(queryRef) {
|
|
7992
|
+
var _a = React.useState(0), forceUpdate = _a[1];
|
|
7993
|
+
var internalQueryRef = queryRef[QUERY_REFERENCE_SYMBOL];
|
|
7994
|
+
invariant__default(internalQueryRef.promiseCache, 49);
|
|
7995
|
+
var skipResult = React.useMemo(function () {
|
|
7996
|
+
var error = toApolloError(internalQueryRef.result);
|
|
7997
|
+
return {
|
|
7998
|
+
loading: false,
|
|
7999
|
+
data: internalQueryRef.result.data,
|
|
8000
|
+
networkStatus: error ? exports.NetworkStatus.error : exports.NetworkStatus.ready,
|
|
8001
|
+
error: error,
|
|
8002
|
+
};
|
|
8003
|
+
}, [internalQueryRef.result]);
|
|
8004
|
+
var promise = internalQueryRef.promiseCache.get(internalQueryRef.key);
|
|
8005
|
+
if (!promise) {
|
|
8006
|
+
promise = internalQueryRef.promise;
|
|
8007
|
+
internalQueryRef.promiseCache.set(internalQueryRef.key, promise);
|
|
8008
|
+
}
|
|
8009
|
+
React.useEffect(function () {
|
|
8010
|
+
return internalQueryRef.listen(function (promise) {
|
|
8011
|
+
internalQueryRef.promiseCache.set(internalQueryRef.key, promise);
|
|
8012
|
+
forceUpdate(function (prevState) { return prevState + 1; });
|
|
8013
|
+
});
|
|
8014
|
+
}, [queryRef]);
|
|
8015
|
+
var result = internalQueryRef.watchQueryOptions.fetchPolicy === 'standby'
|
|
8016
|
+
? skipResult
|
|
8017
|
+
: __use(promise);
|
|
8018
|
+
return React.useMemo(function () {
|
|
8019
|
+
return {
|
|
8020
|
+
data: result.data,
|
|
8021
|
+
networkStatus: result.networkStatus,
|
|
8022
|
+
error: toApolloError(result),
|
|
8023
|
+
};
|
|
8024
|
+
}, [result]);
|
|
8025
|
+
}
|
|
8026
|
+
|
|
7977
8027
|
var SuspenseCache = (function () {
|
|
7978
8028
|
function SuspenseCache(options) {
|
|
7979
8029
|
if (options === void 0) { options = Object.create(null); }
|
|
@@ -7983,7 +8033,7 @@ var SuspenseCache = (function () {
|
|
|
7983
8033
|
SuspenseCache.prototype.getQueryRef = function (cacheKey, createObservable) {
|
|
7984
8034
|
var ref = this.queryRefs.lookupArray(cacheKey);
|
|
7985
8035
|
if (!ref.current) {
|
|
7986
|
-
ref.current = new
|
|
8036
|
+
ref.current = new InternalQueryReference(createObservable(), {
|
|
7987
8037
|
key: cacheKey,
|
|
7988
8038
|
autoDisposeTimeoutMs: this.options.autoDisposeTimeoutMs,
|
|
7989
8039
|
onDispose: function () {
|
|
@@ -7996,7 +8046,7 @@ var SuspenseCache = (function () {
|
|
|
7996
8046
|
return SuspenseCache;
|
|
7997
8047
|
}());
|
|
7998
8048
|
|
|
7999
|
-
exports.setLogVerbosity =
|
|
8049
|
+
exports.setLogVerbosity = invariant$1.setVerbosity;
|
|
8000
8050
|
exports.Observable = zenObservableTs.Observable;
|
|
8001
8051
|
exports.disableExperimentalFragmentVariables = graphqlTag.disableExperimentalFragmentVariables;
|
|
8002
8052
|
exports.disableFragmentWarnings = graphqlTag.disableFragmentWarnings;
|