@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/core/core.cjs.native.js
CHANGED
|
@@ -19,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
19
|
|
|
20
20
|
var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
|
|
21
21
|
|
|
22
|
-
var version = '3.8.0-beta.
|
|
22
|
+
var version = '3.8.0-beta.6';
|
|
23
23
|
|
|
24
24
|
function isNonNullObject(obj) {
|
|
25
25
|
return obj !== null && typeof obj === 'object';
|
|
@@ -223,6 +223,7 @@ var ObservableQuery = (function (_super) {
|
|
|
223
223
|
_this.subscriptions = new Set();
|
|
224
224
|
_this.queryInfo = queryInfo;
|
|
225
225
|
_this.queryManager = queryManager;
|
|
226
|
+
_this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy);
|
|
226
227
|
_this.isTornDown = false;
|
|
227
228
|
var _b = queryManager.defaultOptions.watchQuery, _c = _b === void 0 ? {} : _b, _d = _c.fetchPolicy, defaultFetchPolicy = _d === void 0 ? "cache-first" : _d;
|
|
228
229
|
var _e = options.fetchPolicy, fetchPolicy = _e === void 0 ? defaultFetchPolicy : _e, _f = options.initialFetchPolicy, initialFetchPolicy = _f === void 0 ? (fetchPolicy === "standby" ? defaultFetchPolicy : fetchPolicy) : _f;
|
|
@@ -273,10 +274,11 @@ var ObservableQuery = (function (_super) {
|
|
|
273
274
|
exports.NetworkStatus.ready;
|
|
274
275
|
var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
|
|
275
276
|
var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
|
|
276
|
-
if (fetchPolicy
|
|
277
|
-
fetchPolicy === 'no-cache' ||
|
|
278
|
-
fetchPolicy === 'standby' ||
|
|
277
|
+
if (skipCacheDataFor(fetchPolicy) ||
|
|
279
278
|
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) ;
|
|
279
|
+
else if (this.waitForOwnResult) {
|
|
280
|
+
this.queryInfo['updateWatch']();
|
|
281
|
+
}
|
|
280
282
|
else {
|
|
281
283
|
var diff = this.queryInfo.getDiff();
|
|
282
284
|
if (diff.complete || this.options.returnPartialData) {
|
|
@@ -363,7 +365,7 @@ var ObservableQuery = (function (_super) {
|
|
|
363
365
|
var vars = queryDef.variableDefinitions;
|
|
364
366
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
365
367
|
globals.__DEV__ && globals.invariant.warn(
|
|
366
|
-
|
|
368
|
+
18,
|
|
367
369
|
variables,
|
|
368
370
|
((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
|
|
369
371
|
);
|
|
@@ -454,7 +456,7 @@ var ObservableQuery = (function (_super) {
|
|
|
454
456
|
options.onError(err);
|
|
455
457
|
return;
|
|
456
458
|
}
|
|
457
|
-
globals.__DEV__ && globals.invariant.error(
|
|
459
|
+
globals.__DEV__ && globals.invariant.error(19, err);
|
|
458
460
|
},
|
|
459
461
|
});
|
|
460
462
|
this.subscriptions.add(subscription);
|
|
@@ -467,6 +469,10 @@ var ObservableQuery = (function (_super) {
|
|
|
467
469
|
ObservableQuery.prototype.setOptions = function (newOptions) {
|
|
468
470
|
return this.reobserve(newOptions);
|
|
469
471
|
};
|
|
472
|
+
ObservableQuery.prototype.silentSetOptions = function (newOptions) {
|
|
473
|
+
var mergedOptions = utilities.compact(this.options, newOptions || {});
|
|
474
|
+
assign(this.options, mergedOptions);
|
|
475
|
+
};
|
|
470
476
|
ObservableQuery.prototype.setVariables = function (variables) {
|
|
471
477
|
if (equal.equal(this.variables, variables)) {
|
|
472
478
|
return this.observers.size
|
|
@@ -552,7 +558,7 @@ var ObservableQuery = (function (_super) {
|
|
|
552
558
|
pollingInfo.interval === pollInterval) {
|
|
553
559
|
return;
|
|
554
560
|
}
|
|
555
|
-
globals.invariant(pollInterval,
|
|
561
|
+
globals.invariant(pollInterval, 20);
|
|
556
562
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
557
563
|
info.interval = pollInterval;
|
|
558
564
|
var maybeFetch = function () {
|
|
@@ -614,13 +620,21 @@ var ObservableQuery = (function (_super) {
|
|
|
614
620
|
}
|
|
615
621
|
}
|
|
616
622
|
var fetchOptions = query === options.query ? options : tslib.__assign(tslib.__assign({}, options), { query: query });
|
|
617
|
-
|
|
623
|
+
this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(fetchOptions.fetchPolicy));
|
|
624
|
+
var finishWaitingForOwnResult = function () {
|
|
625
|
+
if (_this.concast === concast) {
|
|
626
|
+
_this.waitForOwnResult = false;
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
var variables = fetchOptions.variables && tslib.__assign({}, fetchOptions.variables);
|
|
618
630
|
var _a = this.fetch(fetchOptions, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
|
|
619
631
|
var observer = {
|
|
620
632
|
next: function (result) {
|
|
633
|
+
finishWaitingForOwnResult();
|
|
621
634
|
_this.reportResult(result, variables);
|
|
622
635
|
},
|
|
623
636
|
error: function (error) {
|
|
637
|
+
finishWaitingForOwnResult();
|
|
624
638
|
_this.reportError(error, variables);
|
|
625
639
|
},
|
|
626
640
|
};
|
|
@@ -697,13 +711,16 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
697
711
|
return obsQuery.reobserve();
|
|
698
712
|
}
|
|
699
713
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
700
|
-
globals.__DEV__ && globals.invariant.error(
|
|
714
|
+
globals.__DEV__ && globals.invariant.error(21, error.message, error.stack);
|
|
701
715
|
}
|
|
702
716
|
function logMissingFieldErrors(missing) {
|
|
703
717
|
if (globals.__DEV__ && missing) {
|
|
704
|
-
globals.__DEV__ && globals.invariant.debug(
|
|
718
|
+
globals.__DEV__ && globals.invariant.debug(22, missing);
|
|
705
719
|
}
|
|
706
720
|
}
|
|
721
|
+
function skipCacheDataFor(fetchPolicy) {
|
|
722
|
+
return fetchPolicy === "network-only" || fetchPolicy === "no-cache" || fetchPolicy === "standby";
|
|
723
|
+
}
|
|
707
724
|
|
|
708
725
|
var LocalState = (function () {
|
|
709
726
|
function LocalState(_a) {
|
|
@@ -880,7 +897,7 @@ var LocalState = (function () {
|
|
|
880
897
|
}
|
|
881
898
|
else {
|
|
882
899
|
fragment = fragmentMap[selection.name.value];
|
|
883
|
-
globals.invariant(fragment,
|
|
900
|
+
globals.invariant(fragment, 16, selection.name.value);
|
|
884
901
|
}
|
|
885
902
|
if (fragment && fragment.typeCondition) {
|
|
886
903
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -993,7 +1010,7 @@ var LocalState = (function () {
|
|
|
993
1010
|
},
|
|
994
1011
|
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
995
1012
|
var fragment = fragmentMap[spread.name.value];
|
|
996
|
-
globals.invariant(fragment,
|
|
1013
|
+
globals.invariant(fragment, 17, spread.name.value);
|
|
997
1014
|
var fragmentSelections = collectByDefinition(fragment);
|
|
998
1015
|
if (fragmentSelections.size > 0) {
|
|
999
1016
|
ancestors.forEach(function (node) {
|
|
@@ -1330,7 +1347,7 @@ var QueryManager = (function () {
|
|
|
1330
1347
|
this.queries.forEach(function (_info, queryId) {
|
|
1331
1348
|
_this.stopQueryNoBroadcast(queryId);
|
|
1332
1349
|
});
|
|
1333
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1350
|
+
this.cancelPendingFetches(globals.newInvariantError(23));
|
|
1334
1351
|
};
|
|
1335
1352
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1336
1353
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1344,9 +1361,9 @@ var QueryManager = (function () {
|
|
|
1344
1361
|
return tslib.__generator(this, function (_h) {
|
|
1345
1362
|
switch (_h.label) {
|
|
1346
1363
|
case 0:
|
|
1347
|
-
globals.invariant(mutation,
|
|
1364
|
+
globals.invariant(mutation, 24);
|
|
1348
1365
|
globals.invariant(fetchPolicy === 'network-only' ||
|
|
1349
|
-
fetchPolicy === 'no-cache',
|
|
1366
|
+
fetchPolicy === 'no-cache', 25);
|
|
1350
1367
|
mutationId = this.generateMutationId();
|
|
1351
1368
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
1352
1369
|
hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
|
|
@@ -1664,10 +1681,10 @@ var QueryManager = (function () {
|
|
|
1664
1681
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1665
1682
|
var _this = this;
|
|
1666
1683
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1667
|
-
globals.invariant(options.query,
|
|
1668
|
-
globals.invariant(options.query.kind === 'Document',
|
|
1669
|
-
globals.invariant(!options.returnPartialData,
|
|
1670
|
-
globals.invariant(!options.pollInterval,
|
|
1684
|
+
globals.invariant(options.query, 26);
|
|
1685
|
+
globals.invariant(options.query.kind === 'Document', 27);
|
|
1686
|
+
globals.invariant(!options.returnPartialData, 28);
|
|
1687
|
+
globals.invariant(!options.pollInterval, 29);
|
|
1671
1688
|
return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
|
|
1672
1689
|
};
|
|
1673
1690
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -1692,7 +1709,7 @@ var QueryManager = (function () {
|
|
|
1692
1709
|
if (options === void 0) { options = {
|
|
1693
1710
|
discardWatches: true,
|
|
1694
1711
|
}; }
|
|
1695
|
-
this.cancelPendingFetches(globals.newInvariantError(
|
|
1712
|
+
this.cancelPendingFetches(globals.newInvariantError(30));
|
|
1696
1713
|
this.queries.forEach(function (queryInfo) {
|
|
1697
1714
|
if (queryInfo.observableQuery) {
|
|
1698
1715
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1768,7 +1785,7 @@ var QueryManager = (function () {
|
|
|
1768
1785
|
if (globals.__DEV__ && queryNamesAndDocs.size) {
|
|
1769
1786
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
1770
1787
|
if (!included) {
|
|
1771
|
-
globals.__DEV__ && globals.invariant.warn(typeof nameOrDoc === "string" ?
|
|
1788
|
+
globals.__DEV__ && globals.invariant.warn(typeof nameOrDoc === "string" ? 31 : 32, nameOrDoc);
|
|
1772
1789
|
}
|
|
1773
1790
|
});
|
|
1774
1791
|
}
|
|
@@ -2230,7 +2247,8 @@ var ApolloClient = (function () {
|
|
|
2230
2247
|
}
|
|
2231
2248
|
}
|
|
2232
2249
|
if (url) {
|
|
2233
|
-
globals.__DEV__ && globals.invariant.log(
|
|
2250
|
+
globals.__DEV__ && globals.invariant.log("Download the Apollo DevTools for a better development " +
|
|
2251
|
+
"experience: %s", url);
|
|
2234
2252
|
}
|
|
2235
2253
|
}
|
|
2236
2254
|
}
|
|
@@ -2293,7 +2311,7 @@ var ApolloClient = (function () {
|
|
|
2293
2311
|
if (this.defaultOptions.query) {
|
|
2294
2312
|
options = utilities.mergeOptions(this.defaultOptions.query, options);
|
|
2295
2313
|
}
|
|
2296
|
-
globals.invariant(options.fetchPolicy !== 'cache-and-network',
|
|
2314
|
+
globals.invariant(options.fetchPolicy !== 'cache-and-network', 14);
|
|
2297
2315
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
2298
2316
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
2299
2317
|
}
|
|
@@ -2382,7 +2400,7 @@ var ApolloClient = (function () {
|
|
|
2382
2400
|
result.queries = queries;
|
|
2383
2401
|
result.results = results;
|
|
2384
2402
|
result.catch(function (error) {
|
|
2385
|
-
globals.__DEV__ && globals.invariant.debug(
|
|
2403
|
+
globals.__DEV__ && globals.invariant.debug(15, error);
|
|
2386
2404
|
});
|
|
2387
2405
|
return result;
|
|
2388
2406
|
};
|