@apollo/client 4.0.10 → 4.0.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/CHANGELOG.md +13 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +16 -1
- package/__cjs/core/ObservableQuery.cjs +18 -7
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +1 -0
- package/__cjs/core/QueryManager.cjs +13 -13
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/invariantErrorCodes.cjs +39 -33
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.cjs +7 -4
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs +2 -0
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.cjs +13 -0
- package/__cjs/utilities/internal/constants.cjs.map +1 -0
- package/__cjs/utilities/internal/constants.d.cts +10 -0
- package/__cjs/utilities/internal/index.cjs +4 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +1 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +16 -1
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +1 -0
- package/core/ObservableQuery.js +19 -8
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +13 -13
- package/core/QueryManager.js.map +1 -1
- package/invariantErrorCodes.js +39 -33
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/package.json +1 -1
- package/react/hooks/useLazyQuery.js +2 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useQuery.js +8 -5
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +2 -0
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +2 -1
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.js +9 -5
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +3 -1
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/utilities/internal/constants.d.ts +10 -0
- package/utilities/internal/constants.js +10 -0
- package/utilities/internal/constants.js.map +1 -0
- package/utilities/internal/index.d.ts +1 -0
- package/utilities/internal/index.js +1 -0
- package/utilities/internal/index.js.map +1 -1
- package/version.js +1 -1
|
@@ -31,6 +31,7 @@ const empty = {
|
|
|
31
31
|
class ObservableQuery {
|
|
32
32
|
options;
|
|
33
33
|
queryName;
|
|
34
|
+
variablesUnknown = false;
|
|
34
35
|
/**
|
|
35
36
|
* @internal will be read and written from `QueryInfo`
|
|
36
37
|
*
|
|
@@ -79,6 +80,10 @@ class ObservableQuery {
|
|
|
79
80
|
const { fetchPolicy = defaultFetchPolicy,
|
|
80
81
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
81
82
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
83
|
+
if (options[internal_1.variablesUnknownSymbol]) {
|
|
84
|
+
(0, invariant_1.invariant)(fetchPolicy === "standby", 77);
|
|
85
|
+
this.variablesUnknown = true;
|
|
86
|
+
}
|
|
82
87
|
this.lastQuery = transformedQuery;
|
|
83
88
|
this.options = {
|
|
84
89
|
...options,
|
|
@@ -380,7 +385,7 @@ class ObservableQuery {
|
|
|
380
385
|
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
381
386
|
const vars = queryDef.variableDefinitions;
|
|
382
387
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
383
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
388
|
+
__DEV__ && invariant_1.invariant.warn(78, variables, queryDef.name?.value || queryDef);
|
|
384
389
|
}
|
|
385
390
|
}
|
|
386
391
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -396,7 +401,7 @@ class ObservableQuery {
|
|
|
396
401
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
397
402
|
(0, invariant_1.invariant)(
|
|
398
403
|
this.options.fetchPolicy !== "cache-only",
|
|
399
|
-
|
|
404
|
+
79,
|
|
400
405
|
(0, internal_1.getOperationName)(this.query, "(anonymous)")
|
|
401
406
|
);
|
|
402
407
|
const combinedOptions = {
|
|
@@ -430,7 +435,7 @@ class ObservableQuery {
|
|
|
430
435
|
let wasUpdated = false;
|
|
431
436
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
432
437
|
if (!isCached) {
|
|
433
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
438
|
+
(0, invariant_1.invariant)(updateQuery, 80);
|
|
434
439
|
}
|
|
435
440
|
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
436
441
|
pushNotification({
|
|
@@ -566,7 +571,7 @@ class ObservableQuery {
|
|
|
566
571
|
onError(error);
|
|
567
572
|
}
|
|
568
573
|
else {
|
|
569
|
-
invariant_1.invariant.error(
|
|
574
|
+
invariant_1.invariant.error(81, error);
|
|
570
575
|
}
|
|
571
576
|
return;
|
|
572
577
|
}
|
|
@@ -810,7 +815,7 @@ class ObservableQuery {
|
|
|
810
815
|
if (!this.didWarnCacheOnlyPolling &&
|
|
811
816
|
pollInterval &&
|
|
812
817
|
fetchPolicy === "cache-only") {
|
|
813
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
818
|
+
__DEV__ && invariant_1.invariant.warn(82, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
|
|
814
819
|
this.didWarnCacheOnlyPolling = true;
|
|
815
820
|
}
|
|
816
821
|
}
|
|
@@ -885,6 +890,10 @@ class ObservableQuery {
|
|
|
885
890
|
const oldVariables = this.variables;
|
|
886
891
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
887
892
|
const mergedOptions = (0, internal_1.compact)(this.options, newOptions || {});
|
|
893
|
+
// This request will hit the network, so even if there are no variables,
|
|
894
|
+
// we now know that's intentional. (see #12996)
|
|
895
|
+
// Even if that happens only once, we want `variablesUnknown` to stay false permanently.
|
|
896
|
+
this.variablesUnknown &&= mergedOptions.fetchPolicy === "standby";
|
|
888
897
|
const options = useDisposableObservable ?
|
|
889
898
|
// Disposable Observable fetches receive a shallow copy of this.options
|
|
890
899
|
// (merged with newOptions), leaving this.options unmodified.
|
|
@@ -1162,7 +1171,9 @@ class ObservableQuery {
|
|
|
1162
1171
|
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1163
1172
|
// as for now we just take the "latest" operation that is still active,
|
|
1164
1173
|
// as that lines up best with previous behavior[]
|
|
1165
|
-
const operation = Array.from(this.activeOperations.values())
|
|
1174
|
+
const operation = Array.from(this.activeOperations.values())
|
|
1175
|
+
.reverse()
|
|
1176
|
+
.find((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
|
|
1166
1177
|
return operation?.override ?? baseNetworkStatus;
|
|
1167
1178
|
}
|
|
1168
1179
|
abortActiveOperations() {
|
|
@@ -1307,7 +1318,7 @@ class ObservableQuery {
|
|
|
1307
1318
|
exports.ObservableQuery = ObservableQuery;
|
|
1308
1319
|
function logMissingFieldErrors(missing) {
|
|
1309
1320
|
if (environment_1.__DEV__ && missing) {
|
|
1310
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1321
|
+
__DEV__ && invariant_1.invariant.debug(83, missing);
|
|
1311
1322
|
}
|
|
1312
1323
|
}
|
|
1313
1324
|
function isEqualQuery(a, b) {
|