@apollo/client 3.7.10 → 3.7.11
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 +177 -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 +52 -15
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +52 -15
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +29 -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 +18 -19
- 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/core/core.cjs
CHANGED
|
@@ -15,16 +15,16 @@ var utils = require('../link/utils');
|
|
|
15
15
|
var tsInvariant = require('ts-invariant');
|
|
16
16
|
var graphqlTag = require('graphql-tag');
|
|
17
17
|
|
|
18
|
-
var version = '3.7.
|
|
19
|
-
|
|
20
|
-
function isNonEmptyArray(value) {
|
|
21
|
-
return Array.isArray(value) && value.length > 0;
|
|
22
|
-
}
|
|
18
|
+
var version = '3.7.11';
|
|
23
19
|
|
|
24
20
|
function isNonNullObject(obj) {
|
|
25
21
|
return obj !== null && typeof obj === 'object';
|
|
26
22
|
}
|
|
27
23
|
|
|
24
|
+
function isNonEmptyArray(value) {
|
|
25
|
+
return Array.isArray(value) && value.length > 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
28
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
29
29
|
var defaultReconciler = function (target, source, property) {
|
|
30
30
|
return this.merge(target[property], source[property]);
|
|
@@ -456,7 +456,7 @@ var ObservableQuery = (function (_super) {
|
|
|
456
456
|
};
|
|
457
457
|
ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
|
|
458
458
|
this.queryManager.setObservableQuery(this);
|
|
459
|
-
return this.queryManager
|
|
459
|
+
return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
|
|
460
460
|
};
|
|
461
461
|
ObservableQuery.prototype.updatePolling = function () {
|
|
462
462
|
var _this = this;
|
|
@@ -509,7 +509,7 @@ var ObservableQuery = (function (_super) {
|
|
|
509
509
|
}
|
|
510
510
|
return this.last;
|
|
511
511
|
};
|
|
512
|
-
ObservableQuery.prototype.
|
|
512
|
+
ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
|
|
513
513
|
var _this = this;
|
|
514
514
|
this.isTornDown = false;
|
|
515
515
|
var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
|
|
@@ -535,7 +535,7 @@ var ObservableQuery = (function (_super) {
|
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
537
|
var variables = options.variables && tslib.__assign({}, options.variables);
|
|
538
|
-
var
|
|
538
|
+
var _a = this.fetch(options, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
539
539
|
var observer = {
|
|
540
540
|
next: function (result) {
|
|
541
541
|
_this.reportResult(result, variables);
|
|
@@ -544,7 +544,7 @@ var ObservableQuery = (function (_super) {
|
|
|
544
544
|
_this.reportError(error, variables);
|
|
545
545
|
},
|
|
546
546
|
};
|
|
547
|
-
if (!useDisposableConcast) {
|
|
547
|
+
if (!useDisposableConcast && fromLink) {
|
|
548
548
|
if (this.concast && this.observer) {
|
|
549
549
|
this.concast.removeObserver(this.observer);
|
|
550
550
|
}
|
|
@@ -552,7 +552,10 @@ var ObservableQuery = (function (_super) {
|
|
|
552
552
|
this.observer = observer;
|
|
553
553
|
}
|
|
554
554
|
concast.addObserver(observer);
|
|
555
|
-
return concast
|
|
555
|
+
return concast;
|
|
556
|
+
};
|
|
557
|
+
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
558
|
+
return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;
|
|
556
559
|
};
|
|
557
560
|
ObservableQuery.prototype.observe = function () {
|
|
558
561
|
this.reportResult(this.getCurrentResult(false), this.variables);
|
|
@@ -1723,10 +1726,17 @@ var QueryManager = (function () {
|
|
|
1723
1726
|
}
|
|
1724
1727
|
_this.broadcastQueries();
|
|
1725
1728
|
}
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
}
|
|
1729
|
+
var hasErrors = utilities.graphQLResultHasError(result);
|
|
1730
|
+
var hasProtocolErrors = errors.graphQLResultHasProtocolErrors(result);
|
|
1731
|
+
if (hasErrors || hasProtocolErrors) {
|
|
1732
|
+
var errors$1 = {};
|
|
1733
|
+
if (hasErrors) {
|
|
1734
|
+
errors$1.graphQLErrors = result.errors;
|
|
1735
|
+
}
|
|
1736
|
+
if (hasProtocolErrors) {
|
|
1737
|
+
errors$1.protocolErrors = result.extensions[errors.PROTOCOL_ERRORS_SYMBOL];
|
|
1738
|
+
}
|
|
1739
|
+
throw new errors.ApolloError(errors$1);
|
|
1730
1740
|
}
|
|
1731
1741
|
return result;
|
|
1732
1742
|
});
|
|
@@ -1858,6 +1868,9 @@ var QueryManager = (function () {
|
|
|
1858
1868
|
});
|
|
1859
1869
|
};
|
|
1860
1870
|
QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
|
|
1871
|
+
return this.fetchConcastWithInfo(queryId, options, networkStatus).concast;
|
|
1872
|
+
};
|
|
1873
|
+
QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
|
|
1861
1874
|
var _this = this;
|
|
1862
1875
|
if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
|
|
1863
1876
|
var query = this.transform(options.query).document;
|
|
@@ -1876,24 +1889,36 @@ var QueryManager = (function () {
|
|
|
1876
1889
|
});
|
|
1877
1890
|
var fromVariables = function (variables) {
|
|
1878
1891
|
normalized.variables = variables;
|
|
1879
|
-
var
|
|
1892
|
+
var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
1880
1893
|
if (normalized.fetchPolicy !== "standby" &&
|
|
1881
|
-
|
|
1894
|
+
sourcesWithInfo.sources.length > 0 &&
|
|
1882
1895
|
queryInfo.observableQuery) {
|
|
1883
1896
|
queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
|
|
1884
1897
|
}
|
|
1885
|
-
return
|
|
1898
|
+
return sourcesWithInfo;
|
|
1886
1899
|
};
|
|
1887
1900
|
var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
|
|
1888
1901
|
this.fetchCancelFns.set(queryId, function (reason) {
|
|
1889
1902
|
cleanupCancelFn();
|
|
1890
1903
|
setTimeout(function () { return concast.cancel(reason); });
|
|
1891
1904
|
});
|
|
1892
|
-
var concast
|
|
1893
|
-
|
|
1894
|
-
|
|
1905
|
+
var concast, containsDataFromLink;
|
|
1906
|
+
if (this.transform(normalized.query).hasClientExports) {
|
|
1907
|
+
concast = new utilities.Concast(this.localState
|
|
1908
|
+
.addExportedVariables(normalized.query, normalized.variables, normalized.context)
|
|
1909
|
+
.then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
|
|
1910
|
+
containsDataFromLink = true;
|
|
1911
|
+
}
|
|
1912
|
+
else {
|
|
1913
|
+
var sourcesWithInfo = fromVariables(normalized.variables);
|
|
1914
|
+
containsDataFromLink = sourcesWithInfo.fromLink;
|
|
1915
|
+
concast = new utilities.Concast(sourcesWithInfo.sources);
|
|
1916
|
+
}
|
|
1895
1917
|
concast.promise.then(cleanupCancelFn, cleanupCancelFn);
|
|
1896
|
-
return
|
|
1918
|
+
return {
|
|
1919
|
+
concast: concast,
|
|
1920
|
+
fromLink: containsDataFromLink,
|
|
1921
|
+
};
|
|
1897
1922
|
};
|
|
1898
1923
|
QueryManager.prototype.refetchQueries = function (_a) {
|
|
1899
1924
|
var _this = this;
|
|
@@ -2017,54 +2042,40 @@ var QueryManager = (function () {
|
|
|
2017
2042
|
case "cache-first": {
|
|
2018
2043
|
var diff = readCache();
|
|
2019
2044
|
if (diff.complete) {
|
|
2020
|
-
return [
|
|
2021
|
-
resultsFromCache(diff, queryInfo.markReady()),
|
|
2022
|
-
];
|
|
2045
|
+
return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
|
|
2023
2046
|
}
|
|
2024
2047
|
if (returnPartialData || shouldNotify) {
|
|
2025
|
-
return [
|
|
2026
|
-
resultsFromCache(diff),
|
|
2027
|
-
resultsFromLink(),
|
|
2028
|
-
];
|
|
2048
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
2029
2049
|
}
|
|
2030
|
-
return [
|
|
2031
|
-
resultsFromLink(),
|
|
2032
|
-
];
|
|
2050
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2033
2051
|
}
|
|
2034
2052
|
case "cache-and-network": {
|
|
2035
2053
|
var diff = readCache();
|
|
2036
2054
|
if (diff.complete || returnPartialData || shouldNotify) {
|
|
2037
|
-
return [
|
|
2038
|
-
resultsFromCache(diff),
|
|
2039
|
-
resultsFromLink(),
|
|
2040
|
-
];
|
|
2055
|
+
return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
|
|
2041
2056
|
}
|
|
2042
|
-
return [
|
|
2043
|
-
resultsFromLink(),
|
|
2044
|
-
];
|
|
2057
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2045
2058
|
}
|
|
2046
2059
|
case "cache-only":
|
|
2047
|
-
return [
|
|
2048
|
-
resultsFromCache(readCache(), queryInfo.markReady()),
|
|
2049
|
-
];
|
|
2060
|
+
return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
|
|
2050
2061
|
case "network-only":
|
|
2051
2062
|
if (shouldNotify) {
|
|
2052
|
-
return [
|
|
2053
|
-
resultsFromCache(readCache()),
|
|
2054
|
-
resultsFromLink(),
|
|
2055
|
-
];
|
|
2063
|
+
return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
|
|
2056
2064
|
}
|
|
2057
|
-
return [resultsFromLink()];
|
|
2065
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2058
2066
|
case "no-cache":
|
|
2059
2067
|
if (shouldNotify) {
|
|
2060
|
-
return
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2068
|
+
return {
|
|
2069
|
+
fromLink: true,
|
|
2070
|
+
sources: [
|
|
2071
|
+
resultsFromCache(queryInfo.getDiff()),
|
|
2072
|
+
resultsFromLink(),
|
|
2073
|
+
],
|
|
2074
|
+
};
|
|
2064
2075
|
}
|
|
2065
|
-
return [resultsFromLink()];
|
|
2076
|
+
return { fromLink: true, sources: [resultsFromLink()] };
|
|
2066
2077
|
case "standby":
|
|
2067
|
-
return [];
|
|
2078
|
+
return { fromLink: false, sources: [] };
|
|
2068
2079
|
}
|
|
2069
2080
|
};
|
|
2070
2081
|
QueryManager.prototype.getQuery = function (queryId) {
|