@apollo/client 4.2.0-alpha.3 → 4.2.0-alpha.5
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 +185 -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 +24 -5
- 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 +28 -9
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +24 -5
- 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 +24 -5
- 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 +28 -9
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +24 -5
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +24 -5
- 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 +28 -9
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +24 -5
- 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
|
@@ -12,7 +12,8 @@ import type { LazyType, OptionWithFallback, SignatureStyle, VariablesOption, var
|
|
|
12
12
|
import { getApolloClientMemoryInternals } from "@apollo/client/utilities/internal";
|
|
13
13
|
import type { DeclareDefaultOptions, DefaultOptions } from "./defaultOptions.cjs";
|
|
14
14
|
import type { ObservableQuery } from "./ObservableQuery.cjs";
|
|
15
|
-
import type {
|
|
15
|
+
import type { RefetchEventManager } from "./RefetchEventManager.cjs";
|
|
16
|
+
import type { DefaultContext, ErrorLike, InternalRefetchQueriesInclude, InternalRefetchQueriesResult, MutationQueryReducersMap, MutationUpdaterFunction, NormalizedExecutionResult, OnQueryUpdated, OperationVariables, RefetchOn, RefetchQueriesInclude, RefetchQueriesPromiseResults, SubscriptionObservable, TypedDocumentNode } from "./types.cjs";
|
|
16
17
|
import type { ErrorPolicy, FetchPolicy, MutationFetchPolicy, NextFetchPolicyContext, RefetchWritePolicy, WatchQueryFetchPolicy } from "./watchQueryOptions.cjs";
|
|
17
18
|
/**
|
|
18
19
|
* @knipignore
|
|
@@ -106,6 +107,11 @@ export declare namespace ApolloClient {
|
|
|
106
107
|
* Do not pass in experiments that are not provided by Apollo.
|
|
107
108
|
*/
|
|
108
109
|
experiments?: ApolloClient.Experiment[];
|
|
110
|
+
/**
|
|
111
|
+
* The `RefetchEventManager` instance that manages automatic refetches for
|
|
112
|
+
* the client.
|
|
113
|
+
*/
|
|
114
|
+
refetchEventManager?: RefetchEventManager;
|
|
109
115
|
}
|
|
110
116
|
export interface DevtoolsOptions {
|
|
111
117
|
/**
|
|
@@ -699,6 +705,25 @@ export declare namespace ApolloClient {
|
|
|
699
705
|
*/
|
|
700
706
|
query: DocumentNode | TypedDocumentNode<TData, TVariables>;
|
|
701
707
|
/**
|
|
708
|
+
* Determines whether events trigger refetches for the query. Provide an
|
|
709
|
+
* object mapping each refetch event to `true` (enable), `false` (disable)
|
|
710
|
+
* or a callback function that returns `true`/`false` to control individual
|
|
711
|
+
* events. Provide `false` to disable all automatic refetch events for this
|
|
712
|
+
* query. Provide `true` to enable all automatic refetch events for this query.
|
|
713
|
+
* Provide a callback function to perform additional logic to determine
|
|
714
|
+
* whether to enable or disable a refetch for a query.
|
|
715
|
+
*
|
|
716
|
+
* `@remarks`
|
|
717
|
+
* `refetchOn` inherits from `defaultOptions.watchQuery.refetchOn`. If
|
|
718
|
+
* `defaultOptions.watchQuery.refetchOn` is not set, all refetch events are
|
|
719
|
+
* enabled by default.
|
|
720
|
+
*
|
|
721
|
+
* This option only has an effect when the client is configured with a
|
|
722
|
+
* `refetchEventManager`.
|
|
723
|
+
* @docGroup 1. Operation options
|
|
724
|
+
*/
|
|
725
|
+
refetchOn?: RefetchOn.Option;
|
|
726
|
+
/**
|
|
702
727
|
* @internal This API is meant for framework integrations only.
|
|
703
728
|
* Do not use for everyday use.
|
|
704
729
|
*
|
|
@@ -965,6 +990,7 @@ export declare class ApolloClient {
|
|
|
965
990
|
queryDeduplication: boolean;
|
|
966
991
|
defaultOptions: ApolloClient.DefaultOptions;
|
|
967
992
|
readonly devtoolsConfig: ApolloClient.DevtoolsOptions;
|
|
993
|
+
readonly refetchEventManager: RefetchEventManager | undefined;
|
|
968
994
|
private queryManager;
|
|
969
995
|
private devToolsHookCb?;
|
|
970
996
|
private resetStoreCallbacks;
|
|
@@ -1017,6 +1043,7 @@ export declare class ApolloClient {
|
|
|
1017
1043
|
* - Unsubscribes all active `ObservableQuery` instances by emitting a `completed` event
|
|
1018
1044
|
* - Rejects all currently running queries with "QueryManager stopped while query was in flight"
|
|
1019
1045
|
* - Removes all queryRefs from the suspense cache
|
|
1046
|
+
* - Disconnects the `RefetchEventManager` if configured.
|
|
1020
1047
|
*/
|
|
1021
1048
|
stop(): void;
|
|
1022
1049
|
/**
|
|
@@ -84,7 +84,7 @@ class ObservableQuery {
|
|
|
84
84
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
85
85
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
86
86
|
if (options[internal_1.variablesUnknownSymbol]) {
|
|
87
|
-
(0, invariant_1.invariant)(fetchPolicy === "standby",
|
|
87
|
+
(0, invariant_1.invariant)(fetchPolicy === "standby", 82);
|
|
88
88
|
this.variablesUnknown = true;
|
|
89
89
|
}
|
|
90
90
|
this.lastQuery = transformedQuery;
|
|
@@ -390,7 +390,7 @@ class ObservableQuery {
|
|
|
390
390
|
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
391
391
|
const vars = queryDef.variableDefinitions;
|
|
392
392
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
393
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
393
|
+
__DEV__ && invariant_1.invariant.warn(83, variables, queryDef.name?.value || queryDef);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -406,7 +406,7 @@ class ObservableQuery {
|
|
|
406
406
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
407
407
|
(0, invariant_1.invariant)(
|
|
408
408
|
this.options.fetchPolicy !== "cache-only",
|
|
409
|
-
|
|
409
|
+
84,
|
|
410
410
|
(0, internal_1.getOperationName)(this.query, "(anonymous)")
|
|
411
411
|
);
|
|
412
412
|
const combinedOptions = {
|
|
@@ -440,7 +440,7 @@ class ObservableQuery {
|
|
|
440
440
|
let wasUpdated = false;
|
|
441
441
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
442
442
|
if (!isCached) {
|
|
443
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
443
|
+
(0, invariant_1.invariant)(updateQuery, 85);
|
|
444
444
|
}
|
|
445
445
|
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
446
446
|
pushNotification({
|
|
@@ -616,7 +616,7 @@ class ObservableQuery {
|
|
|
616
616
|
onError(error);
|
|
617
617
|
}
|
|
618
618
|
else {
|
|
619
|
-
invariant_1.invariant.error(
|
|
619
|
+
invariant_1.invariant.error(86, error);
|
|
620
620
|
}
|
|
621
621
|
return;
|
|
622
622
|
}
|
|
@@ -867,7 +867,7 @@ class ObservableQuery {
|
|
|
867
867
|
if (!this.didWarnCacheOnlyPolling &&
|
|
868
868
|
pollInterval &&
|
|
869
869
|
fetchPolicy === "cache-only") {
|
|
870
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
870
|
+
__DEV__ && invariant_1.invariant.warn(87, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
|
|
871
871
|
this.didWarnCacheOnlyPolling = true;
|
|
872
872
|
}
|
|
873
873
|
}
|
|
@@ -1367,7 +1367,7 @@ class ObservableQuery {
|
|
|
1367
1367
|
exports.ObservableQuery = ObservableQuery;
|
|
1368
1368
|
function logMissingFieldErrors(missing) {
|
|
1369
1369
|
if (environment_1.__DEV__ && missing) {
|
|
1370
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1370
|
+
__DEV__ && invariant_1.invariant.debug(88, missing);
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
1373
|
function isEqualQuery(a, b) {
|