@apollo/client 3.8.0-beta.5 → 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 +102 -74
- 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 +1 -0
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +9 -5
- 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 +25 -20
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +25 -20
- package/dev/dev.cjs +72 -79
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +72 -79
- package/invariantErrorCodes.js +71 -78
- 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 +10 -10
- package/react/cache/QueryReference.d.ts +2 -0
- package/react/cache/QueryReference.d.ts.map +1 -1
- package/react/cache/QueryReference.js +29 -4
- package/react/cache/QueryReference.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 +43 -21
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +43 -21
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useBackgroundQuery.js +3 -4
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useQuery.js +1 -1
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useSubscription.js +2 -2
- package/react/hooks/useSuspenseCache.js +1 -1
- 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 +29 -4
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +29 -4
- 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/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
|
@@ -34,7 +34,7 @@ var invariant__default = /*#__PURE__*/_interopDefaultLegacy(invariant$1);
|
|
|
34
34
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
35
35
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
36
36
|
|
|
37
|
-
var version = '3.8.0-beta.
|
|
37
|
+
var version = '3.8.0-beta.6';
|
|
38
38
|
|
|
39
39
|
function maybe(thunk) {
|
|
40
40
|
try {
|
|
@@ -132,7 +132,7 @@ function shouldInclude(_a, variables) {
|
|
|
132
132
|
var evaledValue = false;
|
|
133
133
|
if (ifArgument.value.kind === 'Variable') {
|
|
134
134
|
evaledValue = variables && variables[ifArgument.value.name.value];
|
|
135
|
-
invariant(evaledValue !== void 0,
|
|
135
|
+
invariant(evaledValue !== void 0, 65, directive.name.value);
|
|
136
136
|
}
|
|
137
137
|
else {
|
|
138
138
|
evaledValue = ifArgument.value.value;
|
|
@@ -168,12 +168,12 @@ function getInclusionDirectives(directives) {
|
|
|
168
168
|
return;
|
|
169
169
|
var directiveArguments = directive.arguments;
|
|
170
170
|
var directiveName = directive.name.value;
|
|
171
|
-
invariant(directiveArguments && directiveArguments.length === 1,
|
|
171
|
+
invariant(directiveArguments && directiveArguments.length === 1, 66, directiveName);
|
|
172
172
|
var ifArgument = directiveArguments[0];
|
|
173
|
-
invariant(ifArgument.name && ifArgument.name.value === 'if',
|
|
173
|
+
invariant(ifArgument.name && ifArgument.name.value === 'if', 67, directiveName);
|
|
174
174
|
var ifValue = ifArgument.value;
|
|
175
175
|
invariant(ifValue &&
|
|
176
|
-
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),
|
|
176
|
+
(ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 68, directiveName);
|
|
177
177
|
result.push({ directive: directive, ifArgument: ifArgument });
|
|
178
178
|
});
|
|
179
179
|
}
|
|
@@ -200,7 +200,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
200
200
|
document.definitions.forEach(function (definition) {
|
|
201
201
|
if (definition.kind === 'OperationDefinition') {
|
|
202
202
|
throw newInvariantError(
|
|
203
|
-
|
|
203
|
+
69,
|
|
204
204
|
definition.operation,
|
|
205
205
|
definition.name ? " named '".concat(definition.name.value, "'") : ''
|
|
206
206
|
);
|
|
@@ -210,7 +210,7 @@ function getFragmentQueryDocument(document, fragmentName) {
|
|
|
210
210
|
}
|
|
211
211
|
});
|
|
212
212
|
if (typeof actualFragmentName === 'undefined') {
|
|
213
|
-
invariant(fragments.length === 1,
|
|
213
|
+
invariant(fragments.length === 1, 70, fragments.length);
|
|
214
214
|
actualFragmentName = fragments[0].name.value;
|
|
215
215
|
}
|
|
216
216
|
var query = tslib.__assign(tslib.__assign({}, document), { definitions: tslib.__spreadArray([
|
|
@@ -251,7 +251,7 @@ function getFragmentFromSelection(selection, fragmentMap) {
|
|
|
251
251
|
return fragmentMap(fragmentName);
|
|
252
252
|
}
|
|
253
253
|
var fragment = fragmentMap && fragmentMap[fragmentName];
|
|
254
|
-
invariant(fragment,
|
|
254
|
+
invariant(fragment, 71, fragmentName);
|
|
255
255
|
return fragment || null;
|
|
256
256
|
}
|
|
257
257
|
default:
|
|
@@ -329,7 +329,7 @@ function valueToObjectRepresentation(argObj, name, value, variables) {
|
|
|
329
329
|
argObj[name.value] = null;
|
|
330
330
|
}
|
|
331
331
|
else {
|
|
332
|
-
throw newInvariantError(
|
|
332
|
+
throw newInvariantError(80, name.value, value.kind);
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
function storeKeyNameFromField(field, variables) {
|
|
@@ -474,16 +474,16 @@ function isInlineFragment(selection) {
|
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
function checkDocument(doc) {
|
|
477
|
-
invariant(doc && doc.kind === 'Document',
|
|
477
|
+
invariant(doc && doc.kind === 'Document', 72);
|
|
478
478
|
var operations = doc.definitions
|
|
479
479
|
.filter(function (d) { return d.kind !== 'FragmentDefinition'; })
|
|
480
480
|
.map(function (definition) {
|
|
481
481
|
if (definition.kind !== 'OperationDefinition') {
|
|
482
|
-
throw newInvariantError(
|
|
482
|
+
throw newInvariantError(73, definition.kind);
|
|
483
483
|
}
|
|
484
484
|
return definition;
|
|
485
485
|
});
|
|
486
|
-
invariant(operations.length <= 1,
|
|
486
|
+
invariant(operations.length <= 1, 74, operations.length);
|
|
487
487
|
return doc;
|
|
488
488
|
}
|
|
489
489
|
function getOperationDefinition(doc) {
|
|
@@ -506,14 +506,14 @@ function getFragmentDefinitions(doc) {
|
|
|
506
506
|
}
|
|
507
507
|
function getQueryDefinition(doc) {
|
|
508
508
|
var queryDef = getOperationDefinition(doc);
|
|
509
|
-
invariant(queryDef && queryDef.operation === 'query',
|
|
509
|
+
invariant(queryDef && queryDef.operation === 'query', 75);
|
|
510
510
|
return queryDef;
|
|
511
511
|
}
|
|
512
512
|
function getFragmentDefinition(doc) {
|
|
513
|
-
invariant(doc.kind === 'Document',
|
|
514
|
-
invariant(doc.definitions.length <= 1,
|
|
513
|
+
invariant(doc.kind === 'Document', 76);
|
|
514
|
+
invariant(doc.definitions.length <= 1, 77);
|
|
515
515
|
var fragmentDef = doc.definitions[0];
|
|
516
|
-
invariant(fragmentDef.kind === 'FragmentDefinition',
|
|
516
|
+
invariant(fragmentDef.kind === 'FragmentDefinition', 78);
|
|
517
517
|
return fragmentDef;
|
|
518
518
|
}
|
|
519
519
|
function getMainDefinition(queryDoc) {
|
|
@@ -536,7 +536,7 @@ function getMainDefinition(queryDoc) {
|
|
|
536
536
|
if (fragmentDefinition) {
|
|
537
537
|
return fragmentDefinition;
|
|
538
538
|
}
|
|
539
|
-
throw newInvariantError(
|
|
539
|
+
throw newInvariantError(79);
|
|
540
540
|
}
|
|
541
541
|
function getDefaultValues(definition) {
|
|
542
542
|
var defaultValues = Object.create(null);
|
|
@@ -608,7 +608,7 @@ var DocumentTransform = (function () {
|
|
|
608
608
|
return;
|
|
609
609
|
var cacheKeys = this.getCacheKey(document);
|
|
610
610
|
if (cacheKeys) {
|
|
611
|
-
invariant(Array.isArray(cacheKeys),
|
|
611
|
+
invariant(Array.isArray(cacheKeys), 64);
|
|
612
612
|
return this.stableCacheKeys.lookupArray(cacheKeys);
|
|
613
613
|
}
|
|
614
614
|
};
|
|
@@ -701,7 +701,7 @@ function removeDirectivesFromDocument(directives, doc) {
|
|
|
701
701
|
return getInUseByFragmentName(ancestor.name.value);
|
|
702
702
|
}
|
|
703
703
|
}
|
|
704
|
-
__DEV__ && invariant.error(
|
|
704
|
+
__DEV__ && invariant.error(81);
|
|
705
705
|
return null;
|
|
706
706
|
};
|
|
707
707
|
var operationCount = 0;
|
|
@@ -978,6 +978,7 @@ function createFulfilledPromise(value) {
|
|
|
978
978
|
}
|
|
979
979
|
function createRejectedPromise(reason) {
|
|
980
980
|
var promise = Promise.reject(reason);
|
|
981
|
+
promise.catch(function () { });
|
|
981
982
|
promise.status = 'rejected';
|
|
982
983
|
promise.reason = reason;
|
|
983
984
|
return promise;
|
|
@@ -1378,7 +1379,7 @@ function toPromise(observable) {
|
|
|
1378
1379
|
observable.subscribe({
|
|
1379
1380
|
next: function (data) {
|
|
1380
1381
|
if (completed) {
|
|
1381
|
-
__DEV__ && invariant.warn(
|
|
1382
|
+
__DEV__ && invariant.warn(40);
|
|
1382
1383
|
}
|
|
1383
1384
|
else {
|
|
1384
1385
|
completed = true;
|
|
@@ -1421,7 +1422,7 @@ function validateOperation(operation) {
|
|
|
1421
1422
|
for (var _i = 0, _a = Object.keys(operation); _i < _a.length; _i++) {
|
|
1422
1423
|
var key = _a[_i];
|
|
1423
1424
|
if (OPERATION_FIELDS.indexOf(key) < 0) {
|
|
1424
|
-
throw newInvariantError(
|
|
1425
|
+
throw newInvariantError(41, key);
|
|
1425
1426
|
}
|
|
1426
1427
|
}
|
|
1427
1428
|
return operation;
|
|
@@ -1528,7 +1529,7 @@ var ApolloLink = (function () {
|
|
|
1528
1529
|
ApolloLink.concat = function (first, second) {
|
|
1529
1530
|
var firstLink = toLink(first);
|
|
1530
1531
|
if (isTerminating(firstLink)) {
|
|
1531
|
-
__DEV__ && invariant.warn(
|
|
1532
|
+
__DEV__ && invariant.warn(33, firstLink);
|
|
1532
1533
|
return firstLink;
|
|
1533
1534
|
}
|
|
1534
1535
|
var nextLink = toLink(second);
|
|
@@ -1552,7 +1553,7 @@ var ApolloLink = (function () {
|
|
|
1552
1553
|
return ApolloLink.concat(this, next);
|
|
1553
1554
|
};
|
|
1554
1555
|
ApolloLink.prototype.request = function (operation, forward) {
|
|
1555
|
-
throw newInvariantError(
|
|
1556
|
+
throw newInvariantError(34);
|
|
1556
1557
|
};
|
|
1557
1558
|
ApolloLink.prototype.onError = function (error, observer) {
|
|
1558
1559
|
if (observer && observer.error) {
|
|
@@ -1927,7 +1928,7 @@ var serializeFetchParameter = function (p, label) {
|
|
|
1927
1928
|
serialized = JSON.stringify(p);
|
|
1928
1929
|
}
|
|
1929
1930
|
catch (e) {
|
|
1930
|
-
var parseError = newInvariantError(
|
|
1931
|
+
var parseError = newInvariantError(37, label, e.message);
|
|
1931
1932
|
parseError.parseError = e;
|
|
1932
1933
|
throw parseError;
|
|
1933
1934
|
}
|
|
@@ -2010,7 +2011,7 @@ function removeDuplicateHeaders(headers, preserveHeaderCase) {
|
|
|
2010
2011
|
|
|
2011
2012
|
var checkFetcher = function (fetcher) {
|
|
2012
2013
|
if (!fetcher && typeof fetch === 'undefined') {
|
|
2013
|
-
throw newInvariantError(
|
|
2014
|
+
throw newInvariantError(35);
|
|
2014
2015
|
}
|
|
2015
2016
|
};
|
|
2016
2017
|
|
|
@@ -2145,7 +2146,7 @@ var createHttpLink = function (linkOptions) {
|
|
|
2145
2146
|
options.headers = options.headers || {};
|
|
2146
2147
|
var acceptHeader = "multipart/mixed;";
|
|
2147
2148
|
if (isSubscription && hasDefer) {
|
|
2148
|
-
__DEV__ && invariant.warn(
|
|
2149
|
+
__DEV__ && invariant.warn(36);
|
|
2149
2150
|
}
|
|
2150
2151
|
if (isSubscription) {
|
|
2151
2152
|
acceptHeader += 'boundary=graphql;subscriptionSpec=1.0,application/json';
|
|
@@ -4765,7 +4766,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4765
4766
|
var vars = queryDef.variableDefinitions;
|
|
4766
4767
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
4767
4768
|
__DEV__ && invariant.warn(
|
|
4768
|
-
|
|
4769
|
+
18,
|
|
4769
4770
|
variables,
|
|
4770
4771
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
4771
4772
|
);
|
|
@@ -4856,7 +4857,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4856
4857
|
options.onError(err);
|
|
4857
4858
|
return;
|
|
4858
4859
|
}
|
|
4859
|
-
__DEV__ && invariant.error(
|
|
4860
|
+
__DEV__ && invariant.error(19, err);
|
|
4860
4861
|
},
|
|
4861
4862
|
});
|
|
4862
4863
|
this.subscriptions.add(subscription);
|
|
@@ -4869,6 +4870,10 @@ var ObservableQuery = (function (_super) {
|
|
|
4869
4870
|
ObservableQuery.prototype.setOptions = function (newOptions) {
|
|
4870
4871
|
return this.reobserve(newOptions);
|
|
4871
4872
|
};
|
|
4873
|
+
ObservableQuery.prototype.silentSetOptions = function (newOptions) {
|
|
4874
|
+
var mergedOptions = compact(this.options, newOptions || {});
|
|
4875
|
+
assign(this.options, mergedOptions);
|
|
4876
|
+
};
|
|
4872
4877
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
4873
4878
|
if (equal.equal(this.variables, variables)) {
|
|
4874
4879
|
return this.observers.size
|
|
@@ -4954,7 +4959,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4954
4959
|
pollingInfo.interval === pollInterval) {
|
|
4955
4960
|
return;
|
|
4956
4961
|
}
|
|
4957
|
-
invariant(pollInterval,
|
|
4962
|
+
invariant(pollInterval, 20);
|
|
4958
4963
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
4959
4964
|
info.interval = pollInterval;
|
|
4960
4965
|
var maybeFetch = function () {
|
|
@@ -5107,11 +5112,11 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
5107
5112
|
return obsQuery.reobserve();
|
|
5108
5113
|
}
|
|
5109
5114
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
5110
|
-
__DEV__ && invariant.error(
|
|
5115
|
+
__DEV__ && invariant.error(21, error.message, error.stack);
|
|
5111
5116
|
}
|
|
5112
5117
|
function logMissingFieldErrors(missing) {
|
|
5113
5118
|
if (__DEV__ && missing) {
|
|
5114
|
-
__DEV__ && invariant.debug(
|
|
5119
|
+
__DEV__ && invariant.debug(22, missing);
|
|
5115
5120
|
}
|
|
5116
5121
|
}
|
|
5117
5122
|
function skipCacheDataFor(fetchPolicy) {
|
|
@@ -5293,7 +5298,7 @@ var LocalState = (function () {
|
|
|
5293
5298
|
}
|
|
5294
5299
|
else {
|
|
5295
5300
|
fragment = fragmentMap[selection.name.value];
|
|
5296
|
-
invariant(fragment,
|
|
5301
|
+
invariant(fragment, 16, selection.name.value);
|
|
5297
5302
|
}
|
|
5298
5303
|
if (fragment && fragment.typeCondition) {
|
|
5299
5304
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -5406,7 +5411,7 @@ var LocalState = (function () {
|
|
|
5406
5411
|
},
|
|
5407
5412
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
5408
5413
|
var fragment = fragmentMap[spread.name.value];
|
|
5409
|
-
invariant(fragment,
|
|
5414
|
+
invariant(fragment, 17, spread.name.value);
|
|
5410
5415
|
var fragmentSelections = collectByDefinition(fragment);
|
|
5411
5416
|
if (fragmentSelections.size > 0) {
|
|
5412
5417
|
ancestors.forEach(function (node) {
|
|
@@ -5743,7 +5748,7 @@ var QueryManager = (function () {
|
|
|
5743
5748
|
this.queries.forEach(function (_info, queryId) {
|
|
5744
5749
|
_this.stopQueryNoBroadcast(queryId);
|
|
5745
5750
|
});
|
|
5746
|
-
this.cancelPendingFetches(newInvariantError(
|
|
5751
|
+
this.cancelPendingFetches(newInvariantError(23));
|
|
5747
5752
|
};
|
|
5748
5753
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
5749
5754
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -5757,9 +5762,9 @@ var QueryManager = (function () {
|
|
|
5757
5762
|
return tslib.__generator(this, function (_h) {
|
|
5758
5763
|
switch (_h.label) {
|
|
5759
5764
|
case 0:
|
|
5760
|
-
invariant(mutation,
|
|
5765
|
+
invariant(mutation, 24);
|
|
5761
5766
|
invariant(fetchPolicy === 'network-only' ||
|
|
5762
|
-
fetchPolicy === 'no-cache',
|
|
5767
|
+
fetchPolicy === 'no-cache', 25);
|
|
5763
5768
|
mutationId = this.generateMutationId();
|
|
5764
5769
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
5765
5770
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -6077,10 +6082,10 @@ var QueryManager = (function () {
|
|
|
6077
6082
|
QueryManager.prototype.query = function (options, queryId) {
|
|
6078
6083
|
var _this = this;
|
|
6079
6084
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
6080
|
-
invariant(options.query,
|
|
6081
|
-
invariant(options.query.kind === 'Document',
|
|
6082
|
-
invariant(!options.returnPartialData,
|
|
6083
|
-
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);
|
|
6084
6089
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
6085
6090
|
};
|
|
6086
6091
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -6105,7 +6110,7 @@ var QueryManager = (function () {
|
|
|
6105
6110
|
if (options === void 0) { options = {
|
|
6106
6111
|
discardWatches: true,
|
|
6107
6112
|
}; }
|
|
6108
|
-
this.cancelPendingFetches(newInvariantError(
|
|
6113
|
+
this.cancelPendingFetches(newInvariantError(30));
|
|
6109
6114
|
this.queries.forEach(function (queryInfo) {
|
|
6110
6115
|
if (queryInfo.observableQuery) {
|
|
6111
6116
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -6181,7 +6186,7 @@ var QueryManager = (function () {
|
|
|
6181
6186
|
if (__DEV__ && queryNamesAndDocs.size) {
|
|
6182
6187
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
6183
6188
|
if (!included) {
|
|
6184
|
-
__DEV__ && invariant.warn(typeof nameOrDoc === "string" ?
|
|
6189
|
+
__DEV__ && invariant.warn(typeof nameOrDoc === "string" ? 31 : 32, nameOrDoc);
|
|
6185
6190
|
}
|
|
6186
6191
|
});
|
|
6187
6192
|
}
|
|
@@ -6643,7 +6648,8 @@ var ApolloClient = (function () {
|
|
|
6643
6648
|
}
|
|
6644
6649
|
}
|
|
6645
6650
|
if (url) {
|
|
6646
|
-
__DEV__ && invariant.log(
|
|
6651
|
+
__DEV__ && invariant.log("Download the Apollo DevTools for a better development " +
|
|
6652
|
+
"experience: %s", url);
|
|
6647
6653
|
}
|
|
6648
6654
|
}
|
|
6649
6655
|
}
|
|
@@ -6706,7 +6712,7 @@ var ApolloClient = (function () {
|
|
|
6706
6712
|
if (this.defaultOptions.query) {
|
|
6707
6713
|
options = mergeOptions(this.defaultOptions.query, options);
|
|
6708
6714
|
}
|
|
6709
|
-
invariant(options.fetchPolicy !== 'cache-and-network',
|
|
6715
|
+
invariant(options.fetchPolicy !== 'cache-and-network', 14);
|
|
6710
6716
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
6711
6717
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
6712
6718
|
}
|
|
@@ -6795,7 +6801,7 @@ var ApolloClient = (function () {
|
|
|
6795
6801
|
result.queries = queries;
|
|
6796
6802
|
result.results = results;
|
|
6797
6803
|
result.catch(function (error) {
|
|
6798
|
-
__DEV__ && invariant.debug(
|
|
6804
|
+
__DEV__ && invariant.debug(15, error);
|
|
6799
6805
|
});
|
|
6800
6806
|
return result;
|
|
6801
6807
|
};
|
|
@@ -6831,7 +6837,7 @@ var contextKey = canUseSymbol
|
|
|
6831
6837
|
? Symbol.for('__APOLLO_CONTEXT__')
|
|
6832
6838
|
: '__APOLLO_CONTEXT__';
|
|
6833
6839
|
function getApolloContext() {
|
|
6834
|
-
invariant('createContext' in React__namespace,
|
|
6840
|
+
invariant('createContext' in React__namespace, 43);
|
|
6835
6841
|
var contextStorage = global$1[contextKey] || (global$1[contextKey] = Object.create(null));
|
|
6836
6842
|
return contextStorage[React__namespace.version] || (contextStorage[React__namespace.version] = Object.assign(React__namespace.createContext({}), { displayName: 'ApolloContext' }));
|
|
6837
6843
|
}
|
|
@@ -6840,7 +6846,7 @@ var resetApolloContext = getApolloContext;
|
|
|
6840
6846
|
var ApolloConsumer = function (props) {
|
|
6841
6847
|
var ApolloContext = getApolloContext();
|
|
6842
6848
|
return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
|
|
6843
|
-
invariant(context && context.client,
|
|
6849
|
+
invariant(context && context.client, 42);
|
|
6844
6850
|
return props.children(context.client);
|
|
6845
6851
|
}));
|
|
6846
6852
|
};
|
|
@@ -6852,14 +6858,14 @@ var ApolloProvider = function (_a) {
|
|
|
6852
6858
|
var context = React__namespace.useMemo(function () {
|
|
6853
6859
|
return tslib.__assign(tslib.__assign({}, parentContext), { client: client || parentContext.client, suspenseCache: suspenseCache || parentContext.suspenseCache });
|
|
6854
6860
|
}, [parentContext, client, suspenseCache]);
|
|
6855
|
-
invariant(context.client,
|
|
6861
|
+
invariant(context.client, 44);
|
|
6856
6862
|
return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
|
|
6857
6863
|
};
|
|
6858
6864
|
|
|
6859
6865
|
function useApolloClient(override) {
|
|
6860
6866
|
var context = React.useContext(getApolloContext());
|
|
6861
6867
|
var client = override || context.client;
|
|
6862
|
-
invariant(!!client,
|
|
6868
|
+
invariant(!!client, 47);
|
|
6863
6869
|
return client;
|
|
6864
6870
|
}
|
|
6865
6871
|
|
|
@@ -6872,7 +6878,7 @@ var useSyncExternalStore = realHook$1 || (function (subscribe, getSnapshot, getS
|
|
|
6872
6878
|
!didWarnUncachedGetSnapshot &&
|
|
6873
6879
|
value !== getSnapshot()) {
|
|
6874
6880
|
didWarnUncachedGetSnapshot = true;
|
|
6875
|
-
__DEV__ && invariant.error(
|
|
6881
|
+
__DEV__ && invariant.error(57);
|
|
6876
6882
|
}
|
|
6877
6883
|
var _a = React__namespace.useState({ inst: { value: value, getSnapshot: getSnapshot } }), inst = _a[0].inst, forceUpdate = _a[1];
|
|
6878
6884
|
if (canUseLayoutEffect) {
|
|
@@ -6935,7 +6941,7 @@ function parser(document) {
|
|
|
6935
6941
|
if (cached)
|
|
6936
6942
|
return cached;
|
|
6937
6943
|
var variables, type, name;
|
|
6938
|
-
invariant(!!document && !!document.kind,
|
|
6944
|
+
invariant(!!document && !!document.kind, 58, document);
|
|
6939
6945
|
var fragments = [];
|
|
6940
6946
|
var queries = [];
|
|
6941
6947
|
var mutations = [];
|
|
@@ -6961,10 +6967,10 @@ function parser(document) {
|
|
|
6961
6967
|
}
|
|
6962
6968
|
}
|
|
6963
6969
|
invariant(!fragments.length ||
|
|
6964
|
-
(queries.length || mutations.length || subscriptions.length),
|
|
6970
|
+
(queries.length || mutations.length || subscriptions.length), 59);
|
|
6965
6971
|
invariant(
|
|
6966
6972
|
queries.length + mutations.length + subscriptions.length <= 1,
|
|
6967
|
-
|
|
6973
|
+
60,
|
|
6968
6974
|
document,
|
|
6969
6975
|
queries.length,
|
|
6970
6976
|
subscriptions.length,
|
|
@@ -6978,7 +6984,7 @@ function parser(document) {
|
|
|
6978
6984
|
: mutations.length
|
|
6979
6985
|
? mutations
|
|
6980
6986
|
: subscriptions;
|
|
6981
|
-
invariant(definitions.length === 1,
|
|
6987
|
+
invariant(definitions.length === 1, 61, document, definitions.length);
|
|
6982
6988
|
var definition = definitions[0];
|
|
6983
6989
|
variables = definition.variableDefinitions || [];
|
|
6984
6990
|
if (definition.name && definition.name.kind === 'Name') {
|
|
@@ -6997,7 +7003,7 @@ function verifyDocumentType(document, type) {
|
|
|
6997
7003
|
var usedOperationName = operationName(operation.type);
|
|
6998
7004
|
invariant(
|
|
6999
7005
|
operation.type === type,
|
|
7000
|
-
|
|
7006
|
+
62,
|
|
7001
7007
|
requiredOperationName,
|
|
7002
7008
|
requiredOperationName,
|
|
7003
7009
|
usedOperationName
|
|
@@ -7048,7 +7054,7 @@ var InternalState = (function () {
|
|
|
7048
7054
|
}
|
|
7049
7055
|
}
|
|
7050
7056
|
InternalState.prototype.forceUpdate = function () {
|
|
7051
|
-
__DEV__ && invariant.warn(
|
|
7057
|
+
__DEV__ && invariant.warn(48);
|
|
7052
7058
|
};
|
|
7053
7059
|
InternalState.prototype.executeQuery = function (options) {
|
|
7054
7060
|
var _this = this;
|
|
@@ -7459,10 +7465,10 @@ function useSubscription(subscription, options) {
|
|
|
7459
7465
|
if (!hasIssuedDeprecationWarningRef.current) {
|
|
7460
7466
|
hasIssuedDeprecationWarningRef.current = true;
|
|
7461
7467
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
|
|
7462
|
-
__DEV__ && invariant.warn(options.onData ?
|
|
7468
|
+
__DEV__ && invariant.warn(options.onData ? 50 : 51);
|
|
7463
7469
|
}
|
|
7464
7470
|
if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
|
|
7465
|
-
__DEV__ && invariant.warn(options.onComplete ?
|
|
7471
|
+
__DEV__ && invariant.warn(options.onComplete ? 52 : 53);
|
|
7466
7472
|
}
|
|
7467
7473
|
}
|
|
7468
7474
|
var _b = React.useState(function () {
|
|
@@ -7673,7 +7679,7 @@ var __use = realHook ||
|
|
|
7673
7679
|
function useSuspenseCache(override) {
|
|
7674
7680
|
var context = React.useContext(getApolloContext());
|
|
7675
7681
|
var suspenseCache = override || context.suspenseCache;
|
|
7676
|
-
invariant(suspenseCache,
|
|
7682
|
+
invariant(suspenseCache, 54);
|
|
7677
7683
|
return suspenseCache;
|
|
7678
7684
|
}
|
|
7679
7685
|
|
|
@@ -7688,11 +7694,10 @@ function useSuspenseQuery(query, options) {
|
|
|
7688
7694
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
7689
7695
|
return client.watchQuery(watchQueryOptions);
|
|
7690
7696
|
});
|
|
7691
|
-
var currentFetchPolicy = queryRef.watchQueryOptions.fetchPolicy;
|
|
7692
7697
|
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
7693
7698
|
var promise = promiseCache.get(queryRef.key);
|
|
7694
|
-
if (
|
|
7695
|
-
promise = queryRef.
|
|
7699
|
+
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
7700
|
+
promise = queryRef.applyOptions(watchQueryOptions);
|
|
7696
7701
|
promiseCache.set(queryRef.key, promise);
|
|
7697
7702
|
}
|
|
7698
7703
|
if (!promise) {
|
|
@@ -7716,7 +7721,7 @@ function useSuspenseQuery(query, options) {
|
|
|
7716
7721
|
error: error,
|
|
7717
7722
|
};
|
|
7718
7723
|
}, [queryRef.result]);
|
|
7719
|
-
var result =
|
|
7724
|
+
var result = fetchPolicy === 'standby' ? skipResult : __use(promise);
|
|
7720
7725
|
var fetchMore = React.useCallback(function (options) {
|
|
7721
7726
|
var promise = queryRef.fetchMore(options);
|
|
7722
7727
|
setPromiseCache(function (previousPromiseCache) {
|
|
@@ -7758,11 +7763,11 @@ function validateFetchPolicy(fetchPolicy) {
|
|
|
7758
7763
|
'no-cache',
|
|
7759
7764
|
'cache-and-network',
|
|
7760
7765
|
];
|
|
7761
|
-
invariant(supportedFetchPolicies.includes(fetchPolicy),
|
|
7766
|
+
invariant(supportedFetchPolicies.includes(fetchPolicy), 55, fetchPolicy);
|
|
7762
7767
|
}
|
|
7763
7768
|
function validatePartialDataReturn(fetchPolicy, returnPartialData) {
|
|
7764
7769
|
if (fetchPolicy === 'no-cache' && returnPartialData) {
|
|
7765
|
-
__DEV__ && invariant.warn(
|
|
7770
|
+
__DEV__ && invariant.warn(56);
|
|
7766
7771
|
}
|
|
7767
7772
|
}
|
|
7768
7773
|
function toApolloError(result) {
|
|
@@ -7796,6 +7801,14 @@ function useWatchQueryOptions(_a) {
|
|
|
7796
7801
|
}
|
|
7797
7802
|
|
|
7798
7803
|
var QUERY_REFERENCE_SYMBOL = Symbol();
|
|
7804
|
+
var OBSERVED_CHANGED_OPTIONS = [
|
|
7805
|
+
'canonizeResults',
|
|
7806
|
+
'context',
|
|
7807
|
+
'errorPolicy',
|
|
7808
|
+
'fetchPolicy',
|
|
7809
|
+
'refetchWritePolicy',
|
|
7810
|
+
'returnPartialData',
|
|
7811
|
+
];
|
|
7799
7812
|
var InternalQueryReference = (function () {
|
|
7800
7813
|
function InternalQueryReference(observable, options) {
|
|
7801
7814
|
var _this = this;
|
|
@@ -7839,6 +7852,25 @@ var InternalQueryReference = (function () {
|
|
|
7839
7852
|
enumerable: false,
|
|
7840
7853
|
configurable: true
|
|
7841
7854
|
});
|
|
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
|
+
};
|
|
7842
7874
|
InternalQueryReference.prototype.listen = function (listener) {
|
|
7843
7875
|
var _this = this;
|
|
7844
7876
|
clearTimeout(this.autoDisposeTimeoutId);
|
|
@@ -7903,10 +7935,7 @@ var InternalQueryReference = (function () {
|
|
|
7903
7935
|
}
|
|
7904
7936
|
return;
|
|
7905
7937
|
}
|
|
7906
|
-
this.
|
|
7907
|
-
this.promise = result.data
|
|
7908
|
-
? createFulfilledPromise(result)
|
|
7909
|
-
: createRejectedPromise(result);
|
|
7938
|
+
this.promise = createRejectedPromise(error);
|
|
7910
7939
|
this.deliver(this.promise);
|
|
7911
7940
|
};
|
|
7912
7941
|
InternalQueryReference.prototype.deliver = function (promise) {
|
|
@@ -7920,16 +7949,15 @@ function useBackgroundQuery(query, options) {
|
|
|
7920
7949
|
var suspenseCache = useSuspenseCache(options.suspenseCache);
|
|
7921
7950
|
var client = useApolloClient(options.client);
|
|
7922
7951
|
var watchQueryOptions = useWatchQueryOptions({ client: client, query: query, options: options });
|
|
7923
|
-
var
|
|
7952
|
+
var variables = watchQueryOptions.variables;
|
|
7924
7953
|
var _a = options.queryKey, queryKey = _a === void 0 ? [] : _a;
|
|
7925
7954
|
var cacheKey = [client, query, canonicalStringify(variables)].concat(queryKey);
|
|
7926
7955
|
var queryRef = suspenseCache.getQueryRef(cacheKey, function () {
|
|
7927
7956
|
return client.watchQuery(watchQueryOptions);
|
|
7928
7957
|
});
|
|
7929
|
-
var currentFetchPolicy = queryRef.watchQueryOptions.fetchPolicy;
|
|
7930
7958
|
var _b = React.useState(function () { return new Map([[queryRef.key, queryRef.promise]]); }), promiseCache = _b[0], setPromiseCache = _b[1];
|
|
7931
|
-
if (
|
|
7932
|
-
var promise = queryRef.
|
|
7959
|
+
if (queryRef.didChangeOptions(watchQueryOptions)) {
|
|
7960
|
+
var promise = queryRef.applyOptions(watchQueryOptions);
|
|
7933
7961
|
promiseCache.set(queryRef.key, promise);
|
|
7934
7962
|
}
|
|
7935
7963
|
useTrackedQueryRefs(queryRef);
|
|
@@ -7963,7 +7991,7 @@ function useBackgroundQuery(query, options) {
|
|
|
7963
7991
|
function useReadQuery(queryRef) {
|
|
7964
7992
|
var _a = React.useState(0), forceUpdate = _a[1];
|
|
7965
7993
|
var internalQueryRef = queryRef[QUERY_REFERENCE_SYMBOL];
|
|
7966
|
-
invariant__default(internalQueryRef.promiseCache,
|
|
7994
|
+
invariant__default(internalQueryRef.promiseCache, 49);
|
|
7967
7995
|
var skipResult = React.useMemo(function () {
|
|
7968
7996
|
var error = toApolloError(internalQueryRef.result);
|
|
7969
7997
|
return {
|