@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
package/core/ObservableQuery.js
CHANGED
|
@@ -2,7 +2,7 @@ import { equal } from "@wry/equality";
|
|
|
2
2
|
import { BehaviorSubject, Observable, share, Subject, tap } from "rxjs";
|
|
3
3
|
import { isNetworkRequestInFlight } from "@apollo/client/utilities";
|
|
4
4
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
5
|
-
import { compact, equalByQuery, filterMap, getOperationDefinition, getOperationName, getQueryDefinition, preventUnhandledRejection, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
5
|
+
import { compact, equalByQuery, filterMap, getOperationDefinition, getOperationName, getQueryDefinition, preventUnhandledRejection, toQueryResult, variablesUnknownSymbol, } from "@apollo/client/utilities/internal";
|
|
6
6
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
7
7
|
import { NetworkStatus } from "./networkStatus.js";
|
|
8
8
|
const { assign, hasOwnProperty } = Object;
|
|
@@ -23,6 +23,7 @@ const empty = {
|
|
|
23
23
|
export class ObservableQuery {
|
|
24
24
|
options;
|
|
25
25
|
queryName;
|
|
26
|
+
variablesUnknown = false;
|
|
26
27
|
/**
|
|
27
28
|
* @internal will be read and written from `QueryInfo`
|
|
28
29
|
*
|
|
@@ -71,6 +72,10 @@ export class ObservableQuery {
|
|
|
71
72
|
const { fetchPolicy = defaultFetchPolicy,
|
|
72
73
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
73
74
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
75
|
+
if (options[variablesUnknownSymbol]) {
|
|
76
|
+
invariant(fetchPolicy === "standby", 77);
|
|
77
|
+
this.variablesUnknown = true;
|
|
78
|
+
}
|
|
74
79
|
this.lastQuery = transformedQuery;
|
|
75
80
|
this.options = {
|
|
76
81
|
...options,
|
|
@@ -372,7 +377,7 @@ export class ObservableQuery {
|
|
|
372
377
|
const queryDef = getQueryDefinition(this.query);
|
|
373
378
|
const vars = queryDef.variableDefinitions;
|
|
374
379
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
375
|
-
__DEV__ && invariant.warn(
|
|
380
|
+
__DEV__ && invariant.warn(78, variables, queryDef.name?.value || queryDef);
|
|
376
381
|
}
|
|
377
382
|
}
|
|
378
383
|
if (variables && !equal(this.variables, variables)) {
|
|
@@ -388,7 +393,7 @@ export class ObservableQuery {
|
|
|
388
393
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
389
394
|
invariant(
|
|
390
395
|
this.options.fetchPolicy !== "cache-only",
|
|
391
|
-
|
|
396
|
+
79,
|
|
392
397
|
getOperationName(this.query, "(anonymous)")
|
|
393
398
|
);
|
|
394
399
|
const combinedOptions = {
|
|
@@ -422,7 +427,7 @@ export class ObservableQuery {
|
|
|
422
427
|
let wasUpdated = false;
|
|
423
428
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
424
429
|
if (!isCached) {
|
|
425
|
-
invariant(updateQuery,
|
|
430
|
+
invariant(updateQuery, 80);
|
|
426
431
|
}
|
|
427
432
|
const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
|
|
428
433
|
pushNotification({
|
|
@@ -558,7 +563,7 @@ export class ObservableQuery {
|
|
|
558
563
|
onError(error);
|
|
559
564
|
}
|
|
560
565
|
else {
|
|
561
|
-
invariant.error(
|
|
566
|
+
invariant.error(81, error);
|
|
562
567
|
}
|
|
563
568
|
return;
|
|
564
569
|
}
|
|
@@ -802,7 +807,7 @@ export class ObservableQuery {
|
|
|
802
807
|
if (!this.didWarnCacheOnlyPolling &&
|
|
803
808
|
pollInterval &&
|
|
804
809
|
fetchPolicy === "cache-only") {
|
|
805
|
-
__DEV__ && invariant.warn(
|
|
810
|
+
__DEV__ && invariant.warn(82, getOperationName(this.query, "(anonymous)"));
|
|
806
811
|
this.didWarnCacheOnlyPolling = true;
|
|
807
812
|
}
|
|
808
813
|
}
|
|
@@ -877,6 +882,10 @@ export class ObservableQuery {
|
|
|
877
882
|
const oldVariables = this.variables;
|
|
878
883
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
879
884
|
const mergedOptions = compact(this.options, newOptions || {});
|
|
885
|
+
// This request will hit the network, so even if there are no variables,
|
|
886
|
+
// we now know that's intentional. (see #12996)
|
|
887
|
+
// Even if that happens only once, we want `variablesUnknown` to stay false permanently.
|
|
888
|
+
this.variablesUnknown &&= mergedOptions.fetchPolicy === "standby";
|
|
880
889
|
const options = useDisposableObservable ?
|
|
881
890
|
// Disposable Observable fetches receive a shallow copy of this.options
|
|
882
891
|
// (merged with newOptions), leaving this.options unmodified.
|
|
@@ -1154,7 +1163,9 @@ export class ObservableQuery {
|
|
|
1154
1163
|
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1155
1164
|
// as for now we just take the "latest" operation that is still active,
|
|
1156
1165
|
// as that lines up best with previous behavior[]
|
|
1157
|
-
const operation = Array.from(this.activeOperations.values())
|
|
1166
|
+
const operation = Array.from(this.activeOperations.values())
|
|
1167
|
+
.reverse()
|
|
1168
|
+
.find((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
|
|
1158
1169
|
return operation?.override ?? baseNetworkStatus;
|
|
1159
1170
|
}
|
|
1160
1171
|
abortActiveOperations() {
|
|
@@ -1298,7 +1309,7 @@ export class ObservableQuery {
|
|
|
1298
1309
|
}
|
|
1299
1310
|
export function logMissingFieldErrors(missing) {
|
|
1300
1311
|
if (__DEV__ && missing) {
|
|
1301
|
-
__DEV__ && invariant.debug(
|
|
1312
|
+
__DEV__ && invariant.debug(83, missing);
|
|
1302
1313
|
}
|
|
1303
1314
|
}
|
|
1304
1315
|
function isEqualQuery(a, b) {
|