@apollo/client 4.2.0-alpha.3 → 4.2.0-alpha.4
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 +179 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +43 -11
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +28 -1
- package/__cjs/core/ObservableQuery.cjs +7 -7
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +20 -1
- package/__cjs/core/QueryManager.cjs +12 -12
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/RefetchEventManager.cjs +134 -0
- package/__cjs/core/RefetchEventManager.cjs.map +1 -0
- package/__cjs/core/RefetchEventManager.d.cts +130 -0
- package/__cjs/core/index.cjs +7 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +4 -1
- package/__cjs/core/refetchSources/onlineSource.cjs +10 -0
- package/__cjs/core/refetchSources/onlineSource.cjs.map +1 -0
- package/__cjs/core/refetchSources/onlineSource.d.cts +3 -0
- package/__cjs/core/refetchSources/windowFocusSource.cjs +13 -0
- package/__cjs/core/refetchSources/windowFocusSource.cjs.map +1 -0
- package/__cjs/core/refetchSources/windowFocusSource.d.cts +3 -0
- package/__cjs/core/types.d.cts +20 -0
- package/__cjs/invariantErrorCodes.cjs +69 -44
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +20 -1
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +20 -1
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +20 -1
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +20 -1
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +20 -1
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -0
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -1
- package/__cjs/react/types/types.documentation.d.cts +19 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +28 -1
- package/core/ApolloClient.js +44 -12
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +20 -1
- package/core/ObservableQuery.js +7 -7
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +12 -12
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.d.ts +130 -0
- package/core/RefetchEventManager.js +126 -0
- package/core/RefetchEventManager.js.map +1 -0
- package/core/index.d.ts +4 -1
- package/core/index.js +3 -0
- package/core/index.js.map +1 -1
- package/core/refetchSources/onlineSource.d.ts +3 -0
- package/core/refetchSources/onlineSource.js +6 -0
- package/core/refetchSources/onlineSource.js.map +1 -0
- package/core/refetchSources/windowFocusSource.d.ts +3 -0
- package/core/refetchSources/windowFocusSource.js +9 -0
- package/core/refetchSources/windowFocusSource.js.map +1 -0
- package/core/types.d.ts +20 -0
- package/core/types.js.map +1 -1
- package/invariantErrorCodes.js +69 -44
- package/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +20 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +20 -1
- package/react/hooks/useLazyQuery.js +1 -0
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +20 -1
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +20 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +20 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +20 -1
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +20 -1
- package/react/hooks-compiled/useLazyQuery.js +1 -0
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +20 -1
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +20 -1
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +20 -1
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +1 -1
- package/react/internal/cache/QueryReference.js +1 -0
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +20 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/types.documentation.d.ts +19 -0
- package/react/types/types.documentation.js.map +1 -1
- package/version.js +1 -1
|
@@ -7,7 +7,7 @@ import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
|
|
|
7
7
|
import type { ApolloClient } from "./ApolloClient.js";
|
|
8
8
|
import { NetworkStatus } from "./networkStatus.js";
|
|
9
9
|
import type { QueryManager } from "./QueryManager.js";
|
|
10
|
-
import type { DataState, DefaultContext, ErrorLike, GetDataState, OperationVariables, TypedDocumentNode } from "./types.js";
|
|
10
|
+
import type { DataState, DefaultContext, ErrorLike, GetDataState, OperationVariables, RefetchOn, TypedDocumentNode } from "./types.js";
|
|
11
11
|
import type { ErrorPolicy, NextFetchPolicyContext, RefetchWritePolicy, SubscribeToMoreUpdateQueryFn, UpdateQueryMapFn, WatchQueryFetchPolicy } from "./watchQueryOptions.js";
|
|
12
12
|
export declare namespace ObservableQuery {
|
|
13
13
|
type Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
|
|
@@ -106,6 +106,25 @@ export declare namespace ObservableQuery {
|
|
|
106
106
|
* @docGroup 1. Operation options
|
|
107
107
|
*/
|
|
108
108
|
variables: TVariables;
|
|
109
|
+
/**
|
|
110
|
+
* Determines whether events trigger refetches for the query. Provide an
|
|
111
|
+
* object mapping each refetch event to `true` (enable), `false` (disable)
|
|
112
|
+
* or a callback function that returns `true`/`false` to control individual
|
|
113
|
+
* events. Provide `false` to disable all automatic refetch events for this
|
|
114
|
+
* query. Provide `true` to enable all automatic refetch events for this query.
|
|
115
|
+
* Provide a callback function to perform additional logic to determine
|
|
116
|
+
* whether to enable or disable a refetch for a query.
|
|
117
|
+
*
|
|
118
|
+
* `@remarks`
|
|
119
|
+
* `refetchOn` inherits from `defaultOptions.watchQuery.refetchOn`. If
|
|
120
|
+
* `defaultOptions.watchQuery.refetchOn` is not set, all refetch events are
|
|
121
|
+
* enabled by default.
|
|
122
|
+
*
|
|
123
|
+
* This option only has an effect when the client is configured with a
|
|
124
|
+
* `refetchEventManager`.
|
|
125
|
+
* @docGroup 1. Operation options
|
|
126
|
+
*/
|
|
127
|
+
refetchOn?: RefetchOn.Option;
|
|
109
128
|
};
|
|
110
129
|
type FetchMoreOptions<TData, TVariables extends OperationVariables, TFetchData = TData, TFetchVars extends OperationVariables = TVariables> = {
|
|
111
130
|
/**
|
package/core/ObservableQuery.js
CHANGED
|
@@ -76,7 +76,7 @@ export class ObservableQuery {
|
|
|
76
76
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
77
77
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
78
78
|
if (options[variablesUnknownSymbol]) {
|
|
79
|
-
invariant(fetchPolicy === "standby",
|
|
79
|
+
invariant(fetchPolicy === "standby", 82);
|
|
80
80
|
this.variablesUnknown = true;
|
|
81
81
|
}
|
|
82
82
|
this.lastQuery = transformedQuery;
|
|
@@ -382,7 +382,7 @@ export class ObservableQuery {
|
|
|
382
382
|
const queryDef = getQueryDefinition(this.query);
|
|
383
383
|
const vars = queryDef.variableDefinitions;
|
|
384
384
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
385
|
-
__DEV__ && invariant.warn(
|
|
385
|
+
__DEV__ && invariant.warn(83, variables, queryDef.name?.value || queryDef);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
if (variables && !equal(this.variables, variables)) {
|
|
@@ -398,7 +398,7 @@ export class ObservableQuery {
|
|
|
398
398
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
399
399
|
invariant(
|
|
400
400
|
this.options.fetchPolicy !== "cache-only",
|
|
401
|
-
|
|
401
|
+
84,
|
|
402
402
|
getOperationName(this.query, "(anonymous)")
|
|
403
403
|
);
|
|
404
404
|
const combinedOptions = {
|
|
@@ -432,7 +432,7 @@ export class ObservableQuery {
|
|
|
432
432
|
let wasUpdated = false;
|
|
433
433
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
434
434
|
if (!isCached) {
|
|
435
|
-
invariant(updateQuery,
|
|
435
|
+
invariant(updateQuery, 85);
|
|
436
436
|
}
|
|
437
437
|
const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
|
|
438
438
|
pushNotification({
|
|
@@ -608,7 +608,7 @@ export class ObservableQuery {
|
|
|
608
608
|
onError(error);
|
|
609
609
|
}
|
|
610
610
|
else {
|
|
611
|
-
invariant.error(
|
|
611
|
+
invariant.error(86, error);
|
|
612
612
|
}
|
|
613
613
|
return;
|
|
614
614
|
}
|
|
@@ -859,7 +859,7 @@ export class ObservableQuery {
|
|
|
859
859
|
if (!this.didWarnCacheOnlyPolling &&
|
|
860
860
|
pollInterval &&
|
|
861
861
|
fetchPolicy === "cache-only") {
|
|
862
|
-
__DEV__ && invariant.warn(
|
|
862
|
+
__DEV__ && invariant.warn(87, getOperationName(this.query, "(anonymous)"));
|
|
863
863
|
this.didWarnCacheOnlyPolling = true;
|
|
864
864
|
}
|
|
865
865
|
}
|
|
@@ -1358,7 +1358,7 @@ export class ObservableQuery {
|
|
|
1358
1358
|
}
|
|
1359
1359
|
export function logMissingFieldErrors(missing) {
|
|
1360
1360
|
if (__DEV__ && missing) {
|
|
1361
|
-
__DEV__ && invariant.debug(
|
|
1361
|
+
__DEV__ && invariant.debug(88, missing);
|
|
1362
1362
|
}
|
|
1363
1363
|
}
|
|
1364
1364
|
function isEqualQuery(a, b) {
|