@apollo/client 4.2.0-alpha.2 → 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 +240 -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 +52 -20
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +159 -22
- 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/link/ws/index.cjs +9 -1
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +1486 -66
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +366 -40
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +512 -50
- package/__cjs/react/hooks/useMutation.cjs +5 -48
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +239 -130
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +590 -41
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +2 -2
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +754 -46
- 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 +159 -22
- package/core/ApolloClient.js +53 -21
- 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/link/ws/index.d.ts +1 -1
- package/link/ws/index.js +9 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +3 -7
- package/react/hooks/useBackgroundQuery.d.ts +1486 -66
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +366 -40
- package/react/hooks/useLazyQuery.js +1 -0
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +512 -50
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +239 -130
- package/react/hooks/useMutation.js +5 -48
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +590 -41
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -2
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +754 -46
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +1486 -66
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +366 -40
- package/react/hooks-compiled/useLazyQuery.js +1 -0
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +512 -50
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +239 -130
- package/react/hooks-compiled/useMutation.js +4 -47
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +590 -41
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.d.ts +2 -2
- package/react/hooks-compiled/useSubscription.js +1 -1
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +754 -46
- 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/skills/apollo-client/SKILL.md +168 -0
- package/skills/apollo-client/references/caching.md +560 -0
- package/skills/apollo-client/references/error-handling.md +350 -0
- package/skills/apollo-client/references/fragments.md +804 -0
- package/skills/apollo-client/references/integration-client.md +336 -0
- package/skills/apollo-client/references/integration-nextjs.md +325 -0
- package/skills/apollo-client/references/integration-react-router.md +256 -0
- package/skills/apollo-client/references/integration-tanstack-start.md +378 -0
- package/skills/apollo-client/references/mutations.md +549 -0
- package/skills/apollo-client/references/queries.md +416 -0
- package/skills/apollo-client/references/state-management.md +428 -0
- package/skills/apollo-client/references/suspense-hooks.md +773 -0
- package/skills/apollo-client/references/troubleshooting.md +487 -0
- package/skills/apollo-client/references/typescript-codegen.md +133 -0
- package/version.js +1 -1
|
@@ -7,7 +7,7 @@ import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
|
|
|
7
7
|
import type { ApolloClient } from "./ApolloClient.cjs";
|
|
8
8
|
import { NetworkStatus } from "./networkStatus.cjs";
|
|
9
9
|
import type { QueryManager } from "./QueryManager.cjs";
|
|
10
|
-
import type { DataState, DefaultContext, ErrorLike, GetDataState, OperationVariables, TypedDocumentNode } from "./types.cjs";
|
|
10
|
+
import type { DataState, DefaultContext, ErrorLike, GetDataState, OperationVariables, RefetchOn, TypedDocumentNode } from "./types.cjs";
|
|
11
11
|
import type { ErrorPolicy, NextFetchPolicyContext, RefetchWritePolicy, SubscribeToMoreUpdateQueryFn, UpdateQueryMapFn, WatchQueryFetchPolicy } from "./watchQueryOptions.cjs";
|
|
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
|
/**
|
|
@@ -99,7 +99,7 @@ class QueryManager {
|
|
|
99
99
|
*/
|
|
100
100
|
stop() {
|
|
101
101
|
this.obsQueries.forEach((oq) => oq.stop());
|
|
102
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
102
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(89));
|
|
103
103
|
}
|
|
104
104
|
cancelPendingFetches(error) {
|
|
105
105
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
@@ -114,7 +114,7 @@ class QueryManager {
|
|
|
114
114
|
if (environment_1.__DEV__) {
|
|
115
115
|
(0, invariant_1.invariant)(
|
|
116
116
|
this.localState,
|
|
117
|
-
|
|
117
|
+
90,
|
|
118
118
|
(0, internal_1.getOperationName)(mutation, "(anonymous)")
|
|
119
119
|
);
|
|
120
120
|
}
|
|
@@ -353,7 +353,7 @@ class QueryManager {
|
|
|
353
353
|
// depend on values that previously existed in the data portion of the
|
|
354
354
|
// store. So, we cancel the promises and observers that we have issued
|
|
355
355
|
// so far and not yet resolved (in the case of queries).
|
|
356
|
-
this.cancelPendingFetches((0, invariant_1.newInvariantError)(
|
|
356
|
+
this.cancelPendingFetches((0, invariant_1.newInvariantError)(91));
|
|
357
357
|
this.obsQueries.forEach((observableQuery) => {
|
|
358
358
|
// Set loading to true so listeners don't trigger unless they want
|
|
359
359
|
// results with partial data.
|
|
@@ -423,10 +423,10 @@ class QueryManager {
|
|
|
423
423
|
if (!included) {
|
|
424
424
|
const queryName = queryNames.get(nameOrQueryString);
|
|
425
425
|
if (queryName) {
|
|
426
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
426
|
+
__DEV__ && invariant_1.invariant.warn(92, queryName);
|
|
427
427
|
}
|
|
428
428
|
else {
|
|
429
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
429
|
+
__DEV__ && invariant_1.invariant.warn(93);
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
});
|
|
@@ -455,7 +455,7 @@ class QueryManager {
|
|
|
455
455
|
if (environment_1.__DEV__) {
|
|
456
456
|
(0, invariant_1.invariant)(
|
|
457
457
|
!this.getDocumentInfo(query).hasClientExports || this.localState,
|
|
458
|
-
|
|
458
|
+
94,
|
|
459
459
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
460
460
|
);
|
|
461
461
|
}
|
|
@@ -599,14 +599,14 @@ class QueryManager {
|
|
|
599
599
|
if (environment_1.__DEV__) {
|
|
600
600
|
(0, invariant_1.invariant)(
|
|
601
601
|
this.localState,
|
|
602
|
-
|
|
602
|
+
95,
|
|
603
603
|
operation[0].toUpperCase() + operation.slice(1),
|
|
604
604
|
operationName ?? "(anonymous)"
|
|
605
605
|
);
|
|
606
606
|
}
|
|
607
607
|
(0, invariant_1.invariant)(
|
|
608
608
|
!hasIncrementalDirective,
|
|
609
|
-
|
|
609
|
+
96,
|
|
610
610
|
operation[0].toUpperCase() + operation.slice(1),
|
|
611
611
|
operationName ?? "(anonymous)"
|
|
612
612
|
);
|
|
@@ -784,7 +784,7 @@ class QueryManager {
|
|
|
784
784
|
if (environment_1.__DEV__) {
|
|
785
785
|
(0, invariant_1.invariant)(
|
|
786
786
|
this.localState,
|
|
787
|
-
|
|
787
|
+
97,
|
|
788
788
|
(0, internal_1.getOperationName)(normalized.query, "(anonymous)")
|
|
789
789
|
);
|
|
790
790
|
}
|
|
@@ -960,7 +960,7 @@ class QueryManager {
|
|
|
960
960
|
!this.noCacheWarningsByCause.has(cause)) {
|
|
961
961
|
this.noCacheWarningsByCause.add(cause);
|
|
962
962
|
__DEV__ && invariant_1.invariant.warn(
|
|
963
|
-
|
|
963
|
+
98,
|
|
964
964
|
(0, internal_1.getOperationName)(document, `Unnamed ${operationType ?? "operation"}`)
|
|
965
965
|
);
|
|
966
966
|
}
|
|
@@ -1022,7 +1022,7 @@ class QueryManager {
|
|
|
1022
1022
|
if (environment_1.__DEV__) {
|
|
1023
1023
|
(0, invariant_1.invariant)(
|
|
1024
1024
|
this.localState,
|
|
1025
|
-
|
|
1025
|
+
99,
|
|
1026
1026
|
(0, internal_1.getOperationName)(query, "(anonymous)")
|
|
1027
1027
|
);
|
|
1028
1028
|
}
|
|
@@ -1118,7 +1118,7 @@ function validateDidEmitValue() {
|
|
|
1118
1118
|
didEmitValue = true;
|
|
1119
1119
|
},
|
|
1120
1120
|
complete() {
|
|
1121
|
-
(0, invariant_1.invariant)(didEmitValue,
|
|
1121
|
+
(0, invariant_1.invariant)(didEmitValue, 100);
|
|
1122
1122
|
},
|
|
1123
1123
|
});
|
|
1124
1124
|
}
|