@apollo/client 3.7.10 → 3.7.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 +182 -145
- 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 +8 -5
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts +1 -0
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +52 -43
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +63 -52
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +63 -52
- 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/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 +19 -3
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +57 -15
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +57 -15
- 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/subscriptions/index.d.ts.map +1 -1
- package/link/subscriptions/index.js +8 -3
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +8 -3
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +8 -3
- package/package.json +22 -23
- package/react/hooks/hooks.cjs +36 -44
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +36 -44
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +11 -20
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +1 -3
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +27 -26
- package/react/hooks/useQuery.js.map +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/react/MockedProvider.js +5 -4
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +4 -2
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +4 -2
- 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/utilities.cjs.map +1 -1
- package/version.js +1 -1
package/apollo-client.cjs
CHANGED
|
@@ -1075,6 +1075,9 @@ function isExecutionPatchResult(value) {
|
|
|
1075
1075
|
return (isExecutionPatchIncrementalResult(value) ||
|
|
1076
1076
|
isExecutionPatchInitialResult(value));
|
|
1077
1077
|
}
|
|
1078
|
+
function isApolloPayloadResult(value) {
|
|
1079
|
+
return isNonNullObject(value) && "payload" in value;
|
|
1080
|
+
}
|
|
1078
1081
|
function mergeIncrementalData(prevResult, result) {
|
|
1079
1082
|
var mergedData = prevResult;
|
|
1080
1083
|
var merger = new DeepMerger();
|
|
@@ -1357,7 +1360,7 @@ var concat = ApolloLink.concat;
|
|
|
1357
1360
|
|
|
1358
1361
|
var execute = ApolloLink.execute;
|
|
1359
1362
|
|
|
1360
|
-
var version = '3.7.
|
|
1363
|
+
var version = '3.7.12';
|
|
1361
1364
|
|
|
1362
1365
|
function isNodeResponse(value) {
|
|
1363
1366
|
return !!value.body;
|
|
@@ -1522,20 +1525,56 @@ function responseIterator(response) {
|
|
|
1522
1525
|
throw new Error("Unknown body type for responseIterator. Please pass a streamable response.");
|
|
1523
1526
|
}
|
|
1524
1527
|
|
|
1528
|
+
var PROTOCOL_ERRORS_SYMBOL = Symbol();
|
|
1529
|
+
function graphQLResultHasProtocolErrors(result) {
|
|
1530
|
+
if (result.extensions) {
|
|
1531
|
+
return Array.isArray(result.extensions[PROTOCOL_ERRORS_SYMBOL]);
|
|
1532
|
+
}
|
|
1533
|
+
return false;
|
|
1534
|
+
}
|
|
1535
|
+
function isApolloError(err) {
|
|
1536
|
+
return err.hasOwnProperty('graphQLErrors');
|
|
1537
|
+
}
|
|
1538
|
+
var generateErrorMessage = function (err) {
|
|
1539
|
+
var errors = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], err.graphQLErrors, true), err.clientErrors, true), err.protocolErrors, true);
|
|
1540
|
+
if (err.networkError)
|
|
1541
|
+
errors.push(err.networkError);
|
|
1542
|
+
return errors
|
|
1543
|
+
.map(function (err) { return isNonNullObject(err) && err.message || 'Error message not found.'; })
|
|
1544
|
+
.join('\n');
|
|
1545
|
+
};
|
|
1546
|
+
var ApolloError = (function (_super) {
|
|
1547
|
+
tslib.__extends(ApolloError, _super);
|
|
1548
|
+
function ApolloError(_a) {
|
|
1549
|
+
var graphQLErrors = _a.graphQLErrors, protocolErrors = _a.protocolErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
1550
|
+
var _this = _super.call(this, errorMessage) || this;
|
|
1551
|
+
_this.name = 'ApolloError';
|
|
1552
|
+
_this.graphQLErrors = graphQLErrors || [];
|
|
1553
|
+
_this.protocolErrors = protocolErrors || [];
|
|
1554
|
+
_this.clientErrors = clientErrors || [];
|
|
1555
|
+
_this.networkError = networkError || null;
|
|
1556
|
+
_this.message = errorMessage || generateErrorMessage(_this);
|
|
1557
|
+
_this.extraInfo = extraInfo;
|
|
1558
|
+
_this.__proto__ = ApolloError.prototype;
|
|
1559
|
+
return _this;
|
|
1560
|
+
}
|
|
1561
|
+
return ApolloError;
|
|
1562
|
+
}(Error));
|
|
1563
|
+
|
|
1525
1564
|
var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1526
1565
|
function readMultipartBody(response, observer) {
|
|
1527
|
-
var _a, _b, _c;
|
|
1566
|
+
var _a, _b, _c, _d, _e;
|
|
1528
1567
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
1529
|
-
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running,
|
|
1530
|
-
var
|
|
1531
|
-
return tslib.__generator(this, function (
|
|
1532
|
-
switch (
|
|
1568
|
+
var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _f, value, done, chunk, bi, message, i, headers, contentType_1, body, result, next;
|
|
1569
|
+
var _g, _h;
|
|
1570
|
+
return tslib.__generator(this, function (_j) {
|
|
1571
|
+
switch (_j.label) {
|
|
1533
1572
|
case 0:
|
|
1534
1573
|
if (TextDecoder === undefined) {
|
|
1535
1574
|
throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
|
|
1536
1575
|
}
|
|
1537
1576
|
decoder = new TextDecoder("utf-8");
|
|
1538
|
-
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get(
|
|
1577
|
+
contentType = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get("content-type");
|
|
1539
1578
|
delimiter = "boundary=";
|
|
1540
1579
|
boundaryVal = (contentType === null || contentType === void 0 ? void 0 : contentType.includes(delimiter))
|
|
1541
1580
|
? 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()
|
|
@@ -1544,22 +1583,22 @@ function readMultipartBody(response, observer) {
|
|
|
1544
1583
|
buffer = "";
|
|
1545
1584
|
iterator = responseIterator(response);
|
|
1546
1585
|
running = true;
|
|
1547
|
-
|
|
1586
|
+
_j.label = 1;
|
|
1548
1587
|
case 1:
|
|
1549
1588
|
if (!running) return [3, 3];
|
|
1550
1589
|
return [4, iterator.next()];
|
|
1551
1590
|
case 2:
|
|
1552
|
-
|
|
1591
|
+
_f = _j.sent(), value = _f.value, done = _f.done;
|
|
1553
1592
|
chunk = typeof value === "string" ? value : decoder.decode(value);
|
|
1554
1593
|
running = !done;
|
|
1555
1594
|
buffer += chunk;
|
|
1556
1595
|
bi = buffer.indexOf(boundary);
|
|
1557
1596
|
while (bi > -1) {
|
|
1558
1597
|
message = void 0;
|
|
1559
|
-
|
|
1598
|
+
_g = [
|
|
1560
1599
|
buffer.slice(0, bi),
|
|
1561
1600
|
buffer.slice(bi + boundary.length),
|
|
1562
|
-
], message =
|
|
1601
|
+
], message = _g[0], buffer = _g[1];
|
|
1563
1602
|
if (message.trim()) {
|
|
1564
1603
|
i = message.indexOf("\r\n\r\n");
|
|
1565
1604
|
headers = parseHeaders(message.slice(0, i));
|
|
@@ -1574,8 +1613,26 @@ function readMultipartBody(response, observer) {
|
|
|
1574
1613
|
if (Object.keys(result).length > 1 ||
|
|
1575
1614
|
"data" in result ||
|
|
1576
1615
|
"incremental" in result ||
|
|
1577
|
-
"errors" in result
|
|
1578
|
-
|
|
1616
|
+
"errors" in result ||
|
|
1617
|
+
"payload" in result) {
|
|
1618
|
+
if (isApolloPayloadResult(result)) {
|
|
1619
|
+
next = {};
|
|
1620
|
+
if ("payload" in result) {
|
|
1621
|
+
next = tslib.__assign({}, result.payload);
|
|
1622
|
+
}
|
|
1623
|
+
if ("errors" in result) {
|
|
1624
|
+
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)) });
|
|
1625
|
+
}
|
|
1626
|
+
(_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, next);
|
|
1627
|
+
}
|
|
1628
|
+
else {
|
|
1629
|
+
(_c = observer.next) === null || _c === void 0 ? void 0 : _c.call(observer, result);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
else if (Object.keys(result).length === 1 &&
|
|
1633
|
+
"hasNext" in result &&
|
|
1634
|
+
!result.hasNext) {
|
|
1635
|
+
(_d = observer.complete) === null || _d === void 0 ? void 0 : _d.call(observer);
|
|
1579
1636
|
}
|
|
1580
1637
|
}
|
|
1581
1638
|
catch (err) {
|
|
@@ -1586,7 +1643,7 @@ function readMultipartBody(response, observer) {
|
|
|
1586
1643
|
}
|
|
1587
1644
|
return [3, 1];
|
|
1588
1645
|
case 3:
|
|
1589
|
-
(
|
|
1646
|
+
(_e = observer.complete) === null || _e === void 0 ? void 0 : _e.call(observer);
|
|
1590
1647
|
return [2];
|
|
1591
1648
|
}
|
|
1592
1649
|
});
|
|
@@ -1884,13 +1941,28 @@ var createHttpLink = function (linkOptions) {
|
|
|
1884
1941
|
var definitionIsMutation = function (d) {
|
|
1885
1942
|
return d.kind === 'OperationDefinition' && d.operation === 'mutation';
|
|
1886
1943
|
};
|
|
1944
|
+
var definitionIsSubscription = function (d) {
|
|
1945
|
+
return d.kind === 'OperationDefinition' && d.operation === 'subscription';
|
|
1946
|
+
};
|
|
1947
|
+
var isSubscription = definitionIsSubscription(getMainDefinition(operation.query));
|
|
1948
|
+
var hasDefer = hasDirectives(['defer'], operation.query);
|
|
1887
1949
|
if (useGETForQueries &&
|
|
1888
1950
|
!operation.query.definitions.some(definitionIsMutation)) {
|
|
1889
1951
|
options.method = 'GET';
|
|
1890
1952
|
}
|
|
1891
|
-
if (
|
|
1953
|
+
if (hasDefer || isSubscription) {
|
|
1892
1954
|
options.headers = options.headers || {};
|
|
1893
|
-
|
|
1955
|
+
var acceptHeader = "multipart/mixed;";
|
|
1956
|
+
if (isSubscription && hasDefer) {
|
|
1957
|
+
__DEV__ && tsInvariant.invariant.warn("Multipart-subscriptions do not support @defer");
|
|
1958
|
+
}
|
|
1959
|
+
if (isSubscription) {
|
|
1960
|
+
acceptHeader += 'boundary=graphql;subscriptionSpec=1.0,application/json';
|
|
1961
|
+
}
|
|
1962
|
+
else if (hasDefer) {
|
|
1963
|
+
acceptHeader += 'deferSpec=20220824,application/json';
|
|
1964
|
+
}
|
|
1965
|
+
options.headers.accept = acceptHeader;
|
|
1894
1966
|
}
|
|
1895
1967
|
if (options.method === 'GET') {
|
|
1896
1968
|
var _d = rewriteURIForGET(chosenURI, body), newURI = _d.newURI, parseError = _d.parseError;
|
|
@@ -4230,44 +4302,6 @@ var InMemoryCache = (function (_super) {
|
|
|
4230
4302
|
return InMemoryCache;
|
|
4231
4303
|
}(ApolloCache));
|
|
4232
4304
|
|
|
4233
|
-
function isApolloError(err) {
|
|
4234
|
-
return err.hasOwnProperty('graphQLErrors');
|
|
4235
|
-
}
|
|
4236
|
-
var generateErrorMessage = function (err) {
|
|
4237
|
-
var message = '';
|
|
4238
|
-
if (isNonEmptyArray(err.graphQLErrors) || isNonEmptyArray(err.clientErrors)) {
|
|
4239
|
-
var errors = (err.graphQLErrors || [])
|
|
4240
|
-
.concat(err.clientErrors || []);
|
|
4241
|
-
errors.forEach(function (error) {
|
|
4242
|
-
var errorMessage = error
|
|
4243
|
-
? error.message
|
|
4244
|
-
: 'Error message not found.';
|
|
4245
|
-
message += "".concat(errorMessage, "\n");
|
|
4246
|
-
});
|
|
4247
|
-
}
|
|
4248
|
-
if (err.networkError) {
|
|
4249
|
-
message += "".concat(err.networkError.message, "\n");
|
|
4250
|
-
}
|
|
4251
|
-
message = message.replace(/\n$/, '');
|
|
4252
|
-
return message;
|
|
4253
|
-
};
|
|
4254
|
-
var ApolloError = (function (_super) {
|
|
4255
|
-
tslib.__extends(ApolloError, _super);
|
|
4256
|
-
function ApolloError(_a) {
|
|
4257
|
-
var graphQLErrors = _a.graphQLErrors, clientErrors = _a.clientErrors, networkError = _a.networkError, errorMessage = _a.errorMessage, extraInfo = _a.extraInfo;
|
|
4258
|
-
var _this = _super.call(this, errorMessage) || this;
|
|
4259
|
-
_this.name = 'ApolloError';
|
|
4260
|
-
_this.graphQLErrors = graphQLErrors || [];
|
|
4261
|
-
_this.clientErrors = clientErrors || [];
|
|
4262
|
-
_this.networkError = networkError || null;
|
|
4263
|
-
_this.message = errorMessage || generateErrorMessage(_this);
|
|
4264
|
-
_this.extraInfo = extraInfo;
|
|
4265
|
-
_this.__proto__ = ApolloError.prototype;
|
|
4266
|
-
return _this;
|
|
4267
|
-
}
|
|
4268
|
-
return ApolloError;
|
|
4269
|
-
}(Error));
|
|
4270
|
-
|
|
4271
4305
|
exports.NetworkStatus = void 0;
|
|
4272
4306
|
(function (NetworkStatus) {
|
|
4273
4307
|
NetworkStatus[NetworkStatus["loading"] = 1] = "loading";
|
|
@@ -4614,7 +4648,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4614
4648
|
};
|
|
4615
4649
|
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
4616
4650
|
this.queryManager.setObservableQuery(this);
|
|
4617
|
-
return this.queryManager
|
|
4651
|
+
return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
|
|
4618
4652
|
};
|
|
4619
4653
|
ObservableQuery.prototype.updatePolling = function () {
|
|
4620
4654
|
var _this = this;
|
|
@@ -4667,7 +4701,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4667
4701
|
}
|
|
4668
4702
|
return this.last;
|
|
4669
4703
|
};
|
|
4670
|
-
ObservableQuery.prototype.
|
|
4704
|
+
ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
|
|
4671
4705
|
var _this = this;
|
|
4672
4706
|
this.isTornDown = false;
|
|
4673
4707
|
var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
|
|
@@ -4693,7 +4727,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4693
4727
|
}
|
|
4694
4728
|
}
|
|
4695
4729
|
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
4696
|
-
var
|
|
4730
|
+
var _a = this.fetch(options, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
4697
4731
|
var observer = {
|
|
4698
4732
|
next: function (result) {
|
|
4699
4733
|
_this.reportResult(result, variables);
|
|
@@ -4702,7 +4736,7 @@ var ObservableQuery = (function (_super) {
|
|
|
4702
4736
|
_this.reportError(error, variables);
|
|
4703
4737
|
},
|
|
4704
4738
|
};
|
|
4705
|
-
if (!useDisposableConcast) {
|
|
4739
|
+
if (!useDisposableConcast && fromLink) {
|
|
4706
4740
|
if (this.concast && this.observer) {
|
|
4707
4741
|
this.concast.removeObserver(this.observer);
|
|
4708
4742
|
}
|
|
@@ -4710,7 +4744,10 @@ var ObservableQuery = (function (_super) {
|
|
|
4710
4744
|
this.observer = observer;
|
|
4711
4745
|
}
|
|
4712
4746
|
concast.addObserver(observer);
|
|
4713
|
-
return concast
|
|
4747
|
+
return concast;
|
|
4748
|
+
};
|
|
4749
|
+
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
4750
|
+
return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;
|
|
4714
4751
|
};
|
|
4715
4752
|
ObservableQuery.prototype.observe = function () {
|
|
4716
4753
|
this.reportResult(this.getCurrentResult(false), this.variables);
|
|
@@ -5881,10 +5918,17 @@ var QueryManager = (function () {
|
|
|
5881
5918
|
}
|
|
5882
5919
|
_this.broadcastQueries();
|
|
5883
5920
|
}
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
}
|
|
5921
|
+
var hasErrors = graphQLResultHasError(result);
|
|
5922
|
+
var hasProtocolErrors = graphQLResultHasProtocolErrors(result);
|
|
5923
|
+
if (hasErrors || hasProtocolErrors) {
|
|
5924
|
+
var errors = {};
|
|
5925
|
+
if (hasErrors) {
|
|
5926
|
+
errors.graphQLErrors = result.errors;
|
|
5927
|
+
}
|
|
5928
|
+
if (hasProtocolErrors) {
|
|
5929
|
+
errors.protocolErrors = result.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
5930
|
+
}
|
|
5931
|
+
throw new ApolloError(errors);
|
|
5888
5932
|
}
|
|
5889
5933
|
return result;
|
|
5890
5934
|
});
|
|
@@ -6016,6 +6060,9 @@ var QueryManager = (function () {
|
|
|
6016
6060
|
});
|
|
6017
6061
|
};
|
|
6018
6062
|
QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
|
|
6063
|
+
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast;
|
|
6064
|
+
};
|
|
6065
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
|
|
6019
6066
|
var _this = this;
|
|
6020
6067
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
6021
6068
|
var query = this.transform(options.query).document;
|
|
@@ -6034,24 +6081,36 @@ var QueryManager = (function () {
|
|
|
6034
6081
|
});
|
|
6035
6082
|
var fromVariables = function (variables) {
|
|
6036
6083
|
normalized.variables = variables;
|
|
6037
|
-
var
|
|
6084
|
+
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
6038
6085
|
if (normalized.fetchPolicy !== "standby" &&
|
|
6039
|
-
|
|
6086
|
+
sourcesWithInfo.sources.length > 0 &&
|
|
6040
6087
|
queryInfo.observableQuery) {
|
|
6041
6088
|
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
6042
6089
|
}
|
|
6043
|
-
return
|
|
6090
|
+
return sourcesWithInfo;
|
|
6044
6091
|
};
|
|
6045
6092
|
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
6046
6093
|
this.fetchCancelFns.set(queryId, function (reason) {
|
|
6047
6094
|
cleanupCancelFn();
|
|
6048
6095
|
setTimeout(function () { return concast.cancel(reason); });
|
|
6049
6096
|
});
|
|
6050
|
-
var concast
|
|
6051
|
-
|
|
6052
|
-
|
|
6097
|
+
var concast, containsDataFromLink;
|
|
6098
|
+
if (this.transform(normalized.query).hasClientExports) {
|
|
6099
|
+
concast = new Concast(this.localState
|
|
6100
|
+
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
6101
|
+
.then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
6102
|
+
containsDataFromLink = true;
|
|
6103
|
+
}
|
|
6104
|
+
else {
|
|
6105
|
+
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
6106
|
+
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
6107
|
+
concast = new Concast(sourcesWithInfo.sources);
|
|
6108
|
+
}
|
|
6053
6109
|
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
6054
|
-
return
|
|
6110
|
+
return {
|
|
6111
|
+
concast: concast,
|
|
6112
|
+
fromLink: containsDataFromLink,
|
|
6113
|
+
};
|
|
6055
6114
|
};
|
|
6056
6115
|
QueryManager.prototype.refetchQueries = function (_a) {
|
|
6057
6116
|
var _this = this;
|
|
@@ -6175,54 +6234,40 @@ var QueryManager = (function () {
|
|
|
6175
6234
|
case "cache-first": {
|
|
6176
6235
|
var diff = readCache();
|
|
6177
6236
|
if (diff.complete) {
|
|
6178
|
-
return [
|
|
6179
|
-
resultsFromCache(diff, queryInfo.markReady()),
|
|
6180
|
-
];
|
|
6237
|
+
return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
|
|
6181
6238
|
}
|
|
6182
6239
|
if (returnPartialData || shouldNotify) {
|
|
6183
|
-
return [
|
|
6184
|
-
resultsFromCache(diff),
|
|
6185
|
-
resultsFromLink(),
|
|
6186
|
-
];
|
|
6240
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6187
6241
|
}
|
|
6188
|
-
return [
|
|
6189
|
-
resultsFromLink(),
|
|
6190
|
-
];
|
|
6242
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6191
6243
|
}
|
|
6192
6244
|
case "cache-and-network": {
|
|
6193
6245
|
var diff = readCache();
|
|
6194
6246
|
if (diff.complete || returnPartialData || shouldNotify) {
|
|
6195
|
-
return [
|
|
6196
|
-
resultsFromCache(diff),
|
|
6197
|
-
resultsFromLink(),
|
|
6198
|
-
];
|
|
6247
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
6199
6248
|
}
|
|
6200
|
-
return [
|
|
6201
|
-
resultsFromLink(),
|
|
6202
|
-
];
|
|
6249
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6203
6250
|
}
|
|
6204
6251
|
case "cache-only":
|
|
6205
|
-
return [
|
|
6206
|
-
resultsFromCache(readCache(), queryInfo.markReady()),
|
|
6207
|
-
];
|
|
6252
|
+
return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
|
|
6208
6253
|
case "network-only":
|
|
6209
6254
|
if (shouldNotify) {
|
|
6210
|
-
return [
|
|
6211
|
-
resultsFromCache(readCache()),
|
|
6212
|
-
resultsFromLink(),
|
|
6213
|
-
];
|
|
6255
|
+
return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
|
|
6214
6256
|
}
|
|
6215
|
-
return [resultsFromLink()];
|
|
6257
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6216
6258
|
case "no-cache":
|
|
6217
6259
|
if (shouldNotify) {
|
|
6218
|
-
return
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6260
|
+
return {
|
|
6261
|
+
fromLink: true,
|
|
6262
|
+
sources: [
|
|
6263
|
+
resultsFromCache(queryInfo.getDiff()),
|
|
6264
|
+
resultsFromLink(),
|
|
6265
|
+
],
|
|
6266
|
+
};
|
|
6222
6267
|
}
|
|
6223
|
-
return [resultsFromLink()];
|
|
6268
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
6224
6269
|
case "standby":
|
|
6225
|
-
return [];
|
|
6270
|
+
return { fromLink: false, sources: [] };
|
|
6226
6271
|
}
|
|
6227
6272
|
};
|
|
6228
6273
|
QueryManager.prototype.getQuery = function (queryId) {
|
|
@@ -6685,8 +6730,6 @@ var InternalState = (function () {
|
|
|
6685
6730
|
function InternalState(client, query, previous) {
|
|
6686
6731
|
this.client = client;
|
|
6687
6732
|
this.query = query;
|
|
6688
|
-
this.asyncResolveFns = new Set();
|
|
6689
|
-
this.optionsToIgnoreOnce = new (canUseWeakSet ? WeakSet : Set)();
|
|
6690
6733
|
this.ssrDisabledResult = maybeDeepFreeze({
|
|
6691
6734
|
loading: true,
|
|
6692
6735
|
data: void 0,
|
|
@@ -6710,20 +6753,30 @@ var InternalState = (function () {
|
|
|
6710
6753
|
InternalState.prototype.forceUpdate = function () {
|
|
6711
6754
|
__DEV__ && tsInvariant.invariant.warn("Calling default no-op implementation of InternalState#forceUpdate");
|
|
6712
6755
|
};
|
|
6713
|
-
InternalState.prototype.
|
|
6756
|
+
InternalState.prototype.executeQuery = function (options) {
|
|
6714
6757
|
var _this = this;
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6758
|
+
var _a;
|
|
6759
|
+
if (options.query) {
|
|
6760
|
+
Object.assign(this, { query: options.query });
|
|
6761
|
+
}
|
|
6762
|
+
this.watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6763
|
+
var concast = this.observable.reobserveAsConcast(this.getObsQueryOptions());
|
|
6764
|
+
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6765
|
+
this.result = void 0;
|
|
6766
|
+
this.forceUpdate();
|
|
6767
|
+
return new Promise(function (resolve) {
|
|
6768
|
+
var result;
|
|
6769
|
+
concast.subscribe({
|
|
6770
|
+
next: function (value) {
|
|
6771
|
+
result = value;
|
|
6772
|
+
},
|
|
6773
|
+
error: function () {
|
|
6774
|
+
resolve(_this.toQueryResult(_this.observable.getCurrentResult()));
|
|
6775
|
+
},
|
|
6776
|
+
complete: function () {
|
|
6777
|
+
resolve(_this.toQueryResult(result));
|
|
6778
|
+
}
|
|
6779
|
+
});
|
|
6727
6780
|
});
|
|
6728
6781
|
};
|
|
6729
6782
|
InternalState.prototype.useQuery = function (options) {
|
|
@@ -6772,29 +6825,22 @@ var InternalState = (function () {
|
|
|
6772
6825
|
}
|
|
6773
6826
|
};
|
|
6774
6827
|
var subscription = obsQuery.subscribe(onNext, onError);
|
|
6775
|
-
return function () { return subscription.unsubscribe(); };
|
|
6828
|
+
return function () { return setTimeout(function () { return subscription.unsubscribe(); }); };
|
|
6776
6829
|
}, [
|
|
6777
6830
|
obsQuery,
|
|
6778
6831
|
this.renderPromises,
|
|
6779
6832
|
this.client.disableNetworkFetches,
|
|
6780
6833
|
]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
|
|
6781
6834
|
this.unsafeHandlePartialRefetch(result);
|
|
6782
|
-
|
|
6783
|
-
if (!queryResult.loading && this.asyncResolveFns.size) {
|
|
6784
|
-
this.asyncResolveFns.forEach(function (resolve) { return resolve(queryResult); });
|
|
6785
|
-
this.asyncResolveFns.clear();
|
|
6786
|
-
}
|
|
6787
|
-
return queryResult;
|
|
6835
|
+
return this.toQueryResult(result);
|
|
6788
6836
|
};
|
|
6789
6837
|
InternalState.prototype.useOptions = function (options) {
|
|
6790
6838
|
var _a;
|
|
6791
6839
|
var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
|
|
6792
6840
|
var currentWatchQueryOptions = this.watchQueryOptions;
|
|
6793
|
-
if (
|
|
6794
|
-
!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
6841
|
+
if (!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
|
|
6795
6842
|
this.watchQueryOptions = watchQueryOptions;
|
|
6796
6843
|
if (currentWatchQueryOptions && this.observable) {
|
|
6797
|
-
this.optionsToIgnoreOnce.delete(currentWatchQueryOptions);
|
|
6798
6844
|
this.observable.reobserve(this.getObsQueryOptions());
|
|
6799
6845
|
this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
|
|
6800
6846
|
this.result = void 0;
|
|
@@ -6960,10 +7006,14 @@ var EAGER_METHODS = [
|
|
|
6960
7006
|
];
|
|
6961
7007
|
function useLazyQuery(query, options) {
|
|
6962
7008
|
var _a;
|
|
6963
|
-
var abortControllersRef = React.useRef(new Set());
|
|
6964
7009
|
var execOptionsRef = React.useRef();
|
|
7010
|
+
var optionsRef = React.useRef();
|
|
7011
|
+
var queryRef = React.useRef();
|
|
6965
7012
|
var merged = execOptionsRef.current ? mergeOptions(options, execOptionsRef.current) : options;
|
|
6966
|
-
var
|
|
7013
|
+
var document = (_a = merged === null || merged === void 0 ? void 0 : merged.query) !== null && _a !== void 0 ? _a : query;
|
|
7014
|
+
optionsRef.current = merged;
|
|
7015
|
+
queryRef.current = document;
|
|
7016
|
+
var internalState = useInternalState(useApolloClient(options && options.client), document);
|
|
6967
7017
|
var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign({}, merged), { skip: !execOptionsRef.current }));
|
|
6968
7018
|
var initialFetchPolicy = useQueryResult.observable.options.initialFetchPolicy ||
|
|
6969
7019
|
internalState.getDefaultFetchPolicy();
|
|
@@ -6989,28 +7039,15 @@ function useLazyQuery(query, options) {
|
|
|
6989
7039
|
return eagerMethods;
|
|
6990
7040
|
}, []);
|
|
6991
7041
|
Object.assign(result, eagerMethods);
|
|
6992
|
-
React.useEffect(function () {
|
|
6993
|
-
return function () {
|
|
6994
|
-
abortControllersRef.current.forEach(function (controller) {
|
|
6995
|
-
controller.abort();
|
|
6996
|
-
});
|
|
6997
|
-
};
|
|
6998
|
-
}, []);
|
|
6999
7042
|
var execute = React.useCallback(function (executeOptions) {
|
|
7000
|
-
var controller = new AbortController();
|
|
7001
|
-
abortControllersRef.current.add(controller);
|
|
7002
7043
|
execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
|
|
7003
7044
|
fetchPolicy: initialFetchPolicy,
|
|
7004
7045
|
};
|
|
7046
|
+
var options = mergeOptions(optionsRef.current, tslib.__assign({ query: queryRef.current }, execOptionsRef.current));
|
|
7005
7047
|
var promise = internalState
|
|
7006
|
-
.
|
|
7007
|
-
.then(function (queryResult) {
|
|
7008
|
-
|
|
7009
|
-
return Object.assign(queryResult, eagerMethods);
|
|
7010
|
-
});
|
|
7011
|
-
promise.catch(function () {
|
|
7012
|
-
abortControllersRef.current.delete(controller);
|
|
7013
|
-
});
|
|
7048
|
+
.executeQuery(tslib.__assign(tslib.__assign({}, options), { skip: false }))
|
|
7049
|
+
.then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
|
|
7050
|
+
promise.catch(function () { });
|
|
7014
7051
|
return promise;
|
|
7015
7052
|
}, []);
|
|
7016
7053
|
return [execute, result];
|