@apollo/client 4.2.0-alpha.8 → 4.2.0
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 +437 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/package.json +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,442 @@
|
|
|
1
1
|
# @apollo/client
|
|
2
2
|
|
|
3
|
+
## 4.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#13132](https://github.com/apollographql/apollo-client/pull/13132) [`f3ce805`](https://github.com/apollographql/apollo-client/commit/f3ce805425d10a9666218a8e109288a2d46dcab1) Thanks [@phryneas](https://github.com/phryneas)! - Introduce "classic" and "modern" method and hook signatures.
|
|
8
|
+
|
|
9
|
+
Apollo Client 4.2 introduces two signature styles for methods and hooks. All signatures previously present are now "classic" signatures, and a new set of "modern" signatures are added alongside them.
|
|
10
|
+
|
|
11
|
+
**Classic signatures** are the default and are identical to the signatures before Apollo Client 4.2, preserving backward compatibility. Classic signatures still work with manually specified TypeScript generics (e.g., `useSuspenseQuery<MyData>(...)`). However, manually specifying generics has been discouraged for a long time—instead, we recommend using `TypedDocumentNode` to automatically infer types, which provides more accurate results without any manual annotations.
|
|
12
|
+
|
|
13
|
+
**Modern signatures** automatically incorporate your declared `defaultOptions` into return types, providing more accurate types. Modern signatures infer types from the document node and do not support manually passing generic type arguments; TypeScript will produce a type error if you attempt to do so.
|
|
14
|
+
|
|
15
|
+
Methods and hooks automatically switch to modern signatures the moment any non-optional property is declared in `DeclareDefaultOptions`. The switch happens across all methods and hooks globally:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// apollo.d.ts
|
|
19
|
+
import "@apollo/client";
|
|
20
|
+
declare module "@apollo/client" {
|
|
21
|
+
namespace ApolloClient {
|
|
22
|
+
namespace DeclareDefaultOptions {
|
|
23
|
+
interface WatchQuery {
|
|
24
|
+
errorPolicy: "all"; // non-optional → modern signatures activated automatically
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Users can also manually switch to modern signatures without declaring any `defaultOptions`, for example when wanting accurate type inference without relying on global `defaultOptions`:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// apollo.d.ts
|
|
35
|
+
import "@apollo/client";
|
|
36
|
+
declare module "@apollo/client" {
|
|
37
|
+
export interface TypeOverrides {
|
|
38
|
+
signatureStyle: "modern";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Users can do a global `DeclareDefaultOptions` type augmentation and then manually switch back to "classic" for migration purposes:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
// apollo.d.ts
|
|
47
|
+
import "@apollo/client";
|
|
48
|
+
declare module "@apollo/client" {
|
|
49
|
+
export interface TypeOverrides {
|
|
50
|
+
signatureStyle: "classic";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Note that this is **not recommended for long-term use**. When combined with `DeclareDefaultOptions`, switching back to classic results in the same incorrect types as before Apollo Client 4.2—methods and hooks will not reflect the `defaultOptions` you've declared.
|
|
56
|
+
|
|
57
|
+
- [#13130](https://github.com/apollographql/apollo-client/pull/13130) [`dd12231`](https://github.com/apollographql/apollo-client/commit/dd122316028b55307de4a40335512307c8fa916a) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Improve the accuracy of `client.query` return type to better detect the current `errorPolicy`. The `data` property is no longer nullable when the `errorPolicy` is `none`. This makes it possible to remove the `undefined` checks or optional chaining in most cases.
|
|
58
|
+
|
|
59
|
+
- [#13210](https://github.com/apollographql/apollo-client/pull/13210) [`1f9a428`](https://github.com/apollographql/apollo-client/commit/1f9a4287eb1eeef2cc08c81c92961f1cecd0dbca) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add support for automatic event-based refetching, such as window focus.
|
|
60
|
+
|
|
61
|
+
The `RefetchEventManager` class handles automatic refetches in response to events. Apollo Client provides built-in sources for window focus and network reconnect as `windowFocusSource` and `onlineSource`.
|
|
62
|
+
|
|
63
|
+
Event refetching is fully opt-in. Create and pass a `RefetchEventManager` instance to the `ApolloClient` constructor to activate the event listeners.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import {
|
|
67
|
+
ApolloClient,
|
|
68
|
+
InMemoryCache,
|
|
69
|
+
RefetchEventManager,
|
|
70
|
+
windowFocusSource,
|
|
71
|
+
onlineSource,
|
|
72
|
+
} from "@apollo/client";
|
|
73
|
+
|
|
74
|
+
const client = new ApolloClient({
|
|
75
|
+
link,
|
|
76
|
+
cache: new InMemoryCache(),
|
|
77
|
+
refetchEventManager: new RefetchEventManager({
|
|
78
|
+
sources: {
|
|
79
|
+
// Refetch when window is focused
|
|
80
|
+
windowFocus: windowFocusSource,
|
|
81
|
+
|
|
82
|
+
// Refetch when the user comes back online
|
|
83
|
+
online: onlineSource,
|
|
84
|
+
},
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
By default, all active queries refetch when the events fire. Queries can opt out per-event or disable all event refetches:
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
// Skip refetch on window focus for this query, but keep `online`
|
|
93
|
+
useQuery(QUERY, {
|
|
94
|
+
refetchOn: { windowFocus: false },
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// Disable all event-driven refetches for this query
|
|
98
|
+
useQuery(OTHER_QUERY, {
|
|
99
|
+
refetchOn: false,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Enable every event for this query, regardless of defaultOptions
|
|
103
|
+
useQuery(LIVE_DASHBOARD, {
|
|
104
|
+
refetchOn: true,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
// Dynamically enable or disable a refetch when the event fires
|
|
108
|
+
useQuery(LIVE_DASHBOARD, {
|
|
109
|
+
refetchOn: ({ source, payload }) => {
|
|
110
|
+
if (source === "windowFocus") {
|
|
111
|
+
// payload is the data associated with the event
|
|
112
|
+
return someCondition(payload);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Dynamically enable or disable a refetch for a specific event
|
|
120
|
+
useQuery(LIVE_DASHBOARD, {
|
|
121
|
+
refetchOn: {
|
|
122
|
+
windowFocus: ({ payload }) => {
|
|
123
|
+
// payload is the data associated with the event
|
|
124
|
+
return someCondition(payload);
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
To enable per-query opt-in rather than opt-out, set `defaultOptions.watchQuery.refetchOn` to `false` and enable it per-query instead.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
const client = new ApolloClient({
|
|
134
|
+
link,
|
|
135
|
+
cache,
|
|
136
|
+
refetchEventManager: new RefetchEventManager({
|
|
137
|
+
sources: { windowFocus: windowFocusSource },
|
|
138
|
+
}),
|
|
139
|
+
defaultOptions: {
|
|
140
|
+
watchQuery: { refetchOn: false },
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Only this query refetches on window focus
|
|
145
|
+
useQuery(DASHBOARD_QUERY, { refetchOn: { windowFocus: true } });
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
When `defaultOptions.watchQuery.refetchOn` and per-query `refetchOn` options are provided, the objects are merged together.
|
|
149
|
+
|
|
150
|
+
### Custom events
|
|
151
|
+
|
|
152
|
+
You can also add your own custom events that trigger refetches. Register your event name and payload type using TypeScript module augmentation, then provide a source function that returns an Observable. The source's emitted value becomes the event's `payload`.
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { Observable } from "@apollo/client";
|
|
156
|
+
import { filter } from "rxjs";
|
|
157
|
+
import { AppState, AppStateStatus, Platform } from "react-native";
|
|
158
|
+
|
|
159
|
+
declare module "@apollo/client" {
|
|
160
|
+
interface RefetchEvents {
|
|
161
|
+
reactNativeAppStatus: AppStateStatus;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const refetchEventManager = new RefetchEventManager({
|
|
166
|
+
sources: {
|
|
167
|
+
reactNativeAppStatus: () => {
|
|
168
|
+
return new Observable((observer) => {
|
|
169
|
+
const subscription = AppState.addEventListener("change", (status) => {
|
|
170
|
+
observer.next(status);
|
|
171
|
+
});
|
|
172
|
+
return () => subscription.remove();
|
|
173
|
+
}).pipe(
|
|
174
|
+
filter((status) => Platform.OS !== "web" && status === "active")
|
|
175
|
+
);
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Disable per-query by setting the event to false
|
|
181
|
+
useQuery(QUERY, { refetchOn: { reactNativeAppStatus: false } });
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Manually trigger an event refetch
|
|
185
|
+
|
|
186
|
+
Refetches can be triggered imperatively by calling `emit` with the event name and its payload (if any).
|
|
187
|
+
|
|
188
|
+
```ts
|
|
189
|
+
refetchEventManager.emit("reactNativeAppStatus", "active");
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Sourceless events
|
|
193
|
+
|
|
194
|
+
A source that has no automatic detection logic but still wants imperative `emit` support can be declared as `true`. Type the event as `void` to omit the payload argument.
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
declare module "@apollo/client" {
|
|
198
|
+
interface RefetchEvents {
|
|
199
|
+
userTriggered: void;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const refetchEventManager = new RefetchEventManager({
|
|
204
|
+
sources: { userTriggered: true },
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
refetchEventManager.emit("userTriggered");
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Note: Calling `emit` on an event without a registered source will log a warning and result in a no-op.
|
|
211
|
+
|
|
212
|
+
### Custom handlers
|
|
213
|
+
|
|
214
|
+
When an event fires, the default handler calls `client.refetchQueries({ include: "active" })` filtered by each query's `refetchOn` setting. You can override the handler for an event to add your own custom filtering. For example, to refetch all queries, including `standby` queries, define a handler for the event:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
const refetchEventManager = new RefetchEventManager({
|
|
218
|
+
// ...
|
|
219
|
+
handlers: {
|
|
220
|
+
userTriggered: ({ client, source, payload, matchesRefetchOn }) => {
|
|
221
|
+
return client.refetchQueries({
|
|
222
|
+
include: "all",
|
|
223
|
+
onQueryUpdated: (observableQuery) => {
|
|
224
|
+
return matchesRefetchOn(observableQuery);
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
Handlers must return either a `RefetchQueriesResult` or `void`. Returning `void` skips refetching for the event.
|
|
233
|
+
|
|
234
|
+
- [#13232](https://github.com/apollographql/apollo-client/pull/13232) [`f1b541f`](https://github.com/apollographql/apollo-client/commit/f1b541fed4111028b6842727178288156582e669) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump to `rc`.
|
|
235
|
+
|
|
236
|
+
- [#13206](https://github.com/apollographql/apollo-client/pull/13206) [`08fccab`](https://github.com/apollographql/apollo-client/commit/08fccab68822e99c6edd539cb4162d1a3df4f4c9) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Extend the `defaultOptions` type-safety work to `client.mutate` and `useMutation`.
|
|
237
|
+
|
|
238
|
+
The `errorPolicy` option now flows through to the result types for mutations in the same way it already does for queries:
|
|
239
|
+
|
|
240
|
+
- `ApolloClient.MutateResult<TData, TErrorPolicy>` maps `errorPolicy` to the concrete shape of `data` and `error`:
|
|
241
|
+
- `"none"` → `{ data: TData; error?: never }`
|
|
242
|
+
- `"all"` → `{ data: TData | undefined; error?: ErrorLike }`
|
|
243
|
+
- `"ignore"` → `{ data: TData | undefined; error?: never }`
|
|
244
|
+
- `client.mutate` and `useMutation` pick up the declared `defaultOptions.mutate.errorPolicy` and the explicit `errorPolicy` on each call to narrow return types accordingly.
|
|
245
|
+
- `useMutation.Result.error` is narrowed to `undefined` when `errorPolicy` is `"ignore"`, since `client.mutate` never resolves with an error in that case.
|
|
246
|
+
|
|
247
|
+
`DeclareDefaultOptions.Mutate` already accepted `errorPolicy`; the new behavior is that once you declare it, hook and method return types reflect it:
|
|
248
|
+
|
|
249
|
+
```ts
|
|
250
|
+
// apollo.d.ts
|
|
251
|
+
import "@apollo/client";
|
|
252
|
+
|
|
253
|
+
declare module "@apollo/client" {
|
|
254
|
+
namespace ApolloClient {
|
|
255
|
+
namespace DeclareDefaultOptions {
|
|
256
|
+
interface Mutate {
|
|
257
|
+
errorPolicy: "all";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
const result = await client.mutate({ mutation: MUTATION });
|
|
266
|
+
result.data;
|
|
267
|
+
// ^? TData | undefined
|
|
268
|
+
result.error;
|
|
269
|
+
// ^? ErrorLike | undefined
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Setting `errorPolicy` on an individual call overrides the default for that call's return type.
|
|
273
|
+
|
|
274
|
+
- [#13222](https://github.com/apollographql/apollo-client/pull/13222) [`b93c172`](https://github.com/apollographql/apollo-client/commit/b93c1723b4b7a9d1296ddd57035bc4fe39c8d971) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Extend the `defaultOptions` type-safety work to `preloadQuery` (returned from `createQueryPreloader`). Defaults declared in `DeclareDefaultOptions.WatchQuery` now work with `preloadQuery` to ensure the `PreloadedQueryRef`'s data states are correctly set.
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
// apollo.d.ts
|
|
278
|
+
import "@apollo/client";
|
|
279
|
+
|
|
280
|
+
declare module "@apollo/client" {
|
|
281
|
+
namespace ApolloClient {
|
|
282
|
+
namespace DeclareDefaultOptions {
|
|
283
|
+
interface WatchQuery {
|
|
284
|
+
errorPolicy: "all";
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
```ts
|
|
292
|
+
const preloadQuery = createQueryPreloader(client);
|
|
293
|
+
const queryRef = preloadQuery(QUERY);
|
|
294
|
+
// ^? PreloadedQueryRef<TData, TVariables, "complete" | "streaming" | "empty">
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
- [#13132](https://github.com/apollographql/apollo-client/pull/13132) [`f3ce805`](https://github.com/apollographql/apollo-client/commit/f3ce805425d10a9666218a8e109288a2d46dcab1) Thanks [@phryneas](https://github.com/phryneas)! - Synchronize method and hook return types with `defaultOptions`.
|
|
298
|
+
|
|
299
|
+
Prior to this change, the following code snippet would always apply:
|
|
300
|
+
|
|
301
|
+
```ts
|
|
302
|
+
declare const MY_QUERY: TypedDocumentNode<TData, TVariables>;
|
|
303
|
+
const result1 = useSuspenseQuery(MY_QUERY);
|
|
304
|
+
result1.data;
|
|
305
|
+
// ^? TData
|
|
306
|
+
const result2 = useSuspenseQuery(MY_QUERY, { errorPolicy: "all" });
|
|
307
|
+
result2.data;
|
|
308
|
+
// ^? TData | undefined
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
While these types are generally correct, if you were to set `errorPolicy: 'all'` as a default option, the type of `result.data` for the first query would remain `TData` instead of changing to `TData | undefined` to match the runtime behavior.
|
|
312
|
+
|
|
313
|
+
We are now enforcing that certain `defaultOptions` types need to be registered globally. This means that if you want to use `errorPolicy: 'all'` as a default option for a query, you will need to register its type like this:
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
// apollo.d.ts
|
|
317
|
+
import "@apollo/client";
|
|
318
|
+
|
|
319
|
+
declare module "@apollo/client" {
|
|
320
|
+
namespace ApolloClient {
|
|
321
|
+
namespace DeclareDefaultOptions {
|
|
322
|
+
interface WatchQuery {
|
|
323
|
+
// possible global-registered values:
|
|
324
|
+
// * `errorPolicy`
|
|
325
|
+
// * `returnPartialData`
|
|
326
|
+
errorPolicy: "all";
|
|
327
|
+
}
|
|
328
|
+
interface Query {
|
|
329
|
+
// possible global-registered values:
|
|
330
|
+
// * `errorPolicy`
|
|
331
|
+
}
|
|
332
|
+
interface Mutate {
|
|
333
|
+
// possible global-registered values:
|
|
334
|
+
// * `errorPolicy`
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Once this type declaration is in place, the type of `result.data` in the above example will correctly be changed to `TData | undefined`, reflecting the possibility that if an error occurs, `data` might be `undefined`. Manually specifying `useSuspenseQuery(MY_QUERY, { errorPolicy: "none" });` changes `result.data` to `TData` to reflect the local override.
|
|
342
|
+
|
|
343
|
+
This change means that you will need to declare your default options types in order to use `defaultOptions` with `ApolloClient`, otherwise you will see a TypeScript error.
|
|
344
|
+
|
|
345
|
+
Without the type declaration, the following (previously valid) code will now error:
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
new ApolloClient({
|
|
349
|
+
link: ApolloLink.empty(),
|
|
350
|
+
cache: new InMemoryCache(),
|
|
351
|
+
defaultOptions: {
|
|
352
|
+
watchQuery: {
|
|
353
|
+
// results in a type error:
|
|
354
|
+
// Type '"all"' is not assignable to type '"A default option for watchQuery.errorPolicy must be declared in ApolloClient.DeclareDefaultOptions before usage. See https://www.apollographql.com/docs/react/data/typescript#declaring-default-options-for-type-safety."'.
|
|
355
|
+
errorPolicy: "all",
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
});
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
If you are creating multiple instances of Apollo Client with conflicting default options and you cannot register a single `defaultOptions` value as a result, you can relax the constraints by declaring those options as union types covering all values used by all clients. The properties can be required (to enforce them in `defaultOptions`) or optional (if some constructor calls won't pass a value):
|
|
362
|
+
|
|
363
|
+
```ts
|
|
364
|
+
// apollo.d.ts
|
|
365
|
+
import "@apollo/client";
|
|
366
|
+
|
|
367
|
+
declare module "@apollo/client" {
|
|
368
|
+
export namespace ApolloClient {
|
|
369
|
+
export namespace DeclareDefaultOptions {
|
|
370
|
+
interface WatchQuery {
|
|
371
|
+
errorPolicy?: "none" | "all" | "ignore";
|
|
372
|
+
returnPartialData?: boolean;
|
|
373
|
+
}
|
|
374
|
+
interface Query {
|
|
375
|
+
errorPolicy?: "none" | "all" | "ignore";
|
|
376
|
+
}
|
|
377
|
+
interface Mutate {
|
|
378
|
+
errorPolicy?: "none" | "all" | "ignore";
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
With this declaration, the `ApolloClient` constructor accepts any of those values in `defaultOptions`. The tradeoff is that hook and method return types become more generic. For example, calling `useSuspenseQuery` without an explicit `errorPolicy` will return a result typed as if all error policies are possible, since TypeScript can't know which specific value your instance uses at runtime.
|
|
386
|
+
|
|
387
|
+
Note that making a property optional (`errorPolicy?:`) is equivalent to adding the TypeScript default value (`"none"`) to the union. So `errorPolicy?: "all" | "ignore"` has the same effect on return types as `errorPolicy: "none" | "all" | "ignore"`, because TypeScript assumes the option could also be absent (i.e., `"none"`).
|
|
388
|
+
|
|
389
|
+
You can also use a **partial union** that only lists the values you actually use. For example, if you only ever use `"all"` or `"ignore"`, declare `errorPolicy: "all" | "ignore"` (required) to keep the union narrow and avoid unused values broadening your signatures unnecessarily.
|
|
390
|
+
|
|
391
|
+
### Patch Changes
|
|
392
|
+
|
|
393
|
+
- [#13217](https://github.com/apollographql/apollo-client/pull/13217) [`790f987`](https://github.com/apollographql/apollo-client/commit/790f987ed65435159dd2c6df5fe2fa01587a179e) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix the deprecation for the classic signatures for function overloads that rely on type inference from a `TypedDocumentNode`. The deprecation now only applies to classic signatures that provide explicit type arguments to encourage the use of `TypedDocumentNode`.
|
|
394
|
+
|
|
395
|
+
- [#13166](https://github.com/apollographql/apollo-client/pull/13166) [`0537d97`](https://github.com/apollographql/apollo-client/commit/0537d97161a51479141a182d869458912e1b8e1d) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Release changes in 4.1.5 and 4.1.6.
|
|
396
|
+
|
|
397
|
+
- [#13215](https://github.com/apollographql/apollo-client/pull/13215) [`54c9eb7`](https://github.com/apollographql/apollo-client/commit/54c9eb7f95d3cd12dc5d12ec27090f1f23b0c471) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Ensure the options object for the `useQuery`, `useSuspenseQuery`, and `useBackgroundQuery` hooks provide proper IntelliSense suggestions.
|
|
398
|
+
|
|
399
|
+
- [#13229](https://github.com/apollographql/apollo-client/pull/13229) [`9a7f65a`](https://github.com/apollographql/apollo-client/commit/9a7f65a0059433c83307ef2d8117dac67947d791) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Fix `refetchOn` merging when `defaultOptions.watchQuery.refetchOn` is set to a non-object value (`false`, `true`, or a function) and the per-query `refetchOn` is an object. Previously the per-query object completely replaced the default so unspecified events fell back to "enabled" regardless of the default.
|
|
400
|
+
|
|
401
|
+
The `defaultOptions` value now applies to any event the per-query object does not explicitly configure:
|
|
402
|
+
|
|
403
|
+
- `false` - unspecified events stay disabled
|
|
404
|
+
- `true` - unspecified events refetch
|
|
405
|
+
- Callback function - the function is called for unspecified events to determine whether to refetch
|
|
406
|
+
|
|
407
|
+
```ts
|
|
408
|
+
const client = new ApolloClient({
|
|
409
|
+
// ...
|
|
410
|
+
defaultOptions: {
|
|
411
|
+
watchQuery: {
|
|
412
|
+
refetchOn: false,
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// Only `windowFocus` refetches. Other events stay disabled per the default.
|
|
418
|
+
useQuery(QUERY, { refetchOn: { windowFocus: true } });
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
- [#13230](https://github.com/apollographql/apollo-client/pull/13230) [`b25b659`](https://github.com/apollographql/apollo-client/commit/b25b6593f5d968db505b127e7ff7f2bb2419d5ee) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to override the default event handler on `RefetchEventManager`. The default handler runs when no per-source handler is configured for an event. Provide a custom handler via the `defaultHandler` constructor option or the `setDefaultEventHandler` instance method.
|
|
422
|
+
|
|
423
|
+
```ts
|
|
424
|
+
new RefetchEventManager({
|
|
425
|
+
defaultHandler: ({ client, matchesRefetchOn }) => {
|
|
426
|
+
return client.refetchQueries({
|
|
427
|
+
include: "all",
|
|
428
|
+
onQueryUpdated: matchesRefetchOn,
|
|
429
|
+
});
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
## 4.2.0-rc.0
|
|
435
|
+
|
|
436
|
+
### Minor Changes
|
|
437
|
+
|
|
438
|
+
- [#13232](https://github.com/apollographql/apollo-client/pull/13232) [`f1b541f`](https://github.com/apollographql/apollo-client/commit/f1b541fed4111028b6842727178288156582e669) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Version bump to `rc`.
|
|
439
|
+
|
|
3
440
|
## 4.2.0-alpha.8
|
|
4
441
|
|
|
5
442
|
### Patch Changes
|
package/__cjs/version.cjs
CHANGED
package/__cjs/version.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.cjs","sources":["../../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":";;;AAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"version.cjs","sources":["../../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":";;;AAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAwC;AAC3B,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,CAAb,CAAA,CAAA,CAAA,EAAA,OAAyD;"}
|
package/package.json
CHANGED
package/version.js
CHANGED
package/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../src/version.ts"],"sourcesContent":["export const version = \"local\" as string;\nexport const build = \"source\" as \"source\" | \"esm\" | \"cjs\";\n"],"names":[],"mappings":"AAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,SAAwC;AACxC,CAAA,CAAA,CAAA,CAAA,CAAA,EAAO,CAAP,CAAA,CAAA,CAAA,EAAa,CAAb,CAAA,CAAA,CAAA,EAAA,OAAyD;"}
|