@tanstack/query-core 5.0.0-alpha.21 → 5.0.0-alpha.23
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/build/lib/queryClient.esm.js +2 -2
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js +2 -2
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryClient.mjs +2 -2
- package/build/lib/queryClient.mjs.map +1 -1
- package/build/lib/queryObserver.esm.js +3 -3
- package/build/lib/queryObserver.esm.js.map +1 -1
- package/build/lib/queryObserver.js +3 -3
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/queryObserver.mjs +2 -2
- package/build/lib/queryObserver.mjs.map +1 -1
- package/build/lib/types.d.ts +6 -6
- package/build/umd/index.development.js +4 -4
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/queryClient.ts +2 -2
- package/src/queryObserver.ts +9 -7
- package/src/types.ts +6 -6
package/package.json
CHANGED
package/src/queryClient.ts
CHANGED
|
@@ -478,8 +478,8 @@ export class QueryClient {
|
|
|
478
478
|
defaultedOptions.refetchOnReconnect =
|
|
479
479
|
defaultedOptions.networkMode !== 'always'
|
|
480
480
|
}
|
|
481
|
-
if (typeof defaultedOptions.
|
|
482
|
-
defaultedOptions.
|
|
481
|
+
if (typeof defaultedOptions.throwOnError === 'undefined') {
|
|
482
|
+
defaultedOptions.throwOnError = !!defaultedOptions.suspense
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
return defaultedOptions as DefaultedQueryObserverOptions<
|
package/src/queryObserver.ts
CHANGED
|
@@ -342,12 +342,14 @@ export class QueryObserver<
|
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
#computeRefetchInterval() {
|
|
345
|
-
return
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
345
|
+
return (
|
|
346
|
+
(typeof this.options.refetchInterval === 'function'
|
|
347
|
+
? this.options.refetchInterval(
|
|
348
|
+
this.#currentResult.data,
|
|
349
|
+
this.#currentQuery,
|
|
350
|
+
)
|
|
351
|
+
: this.options.refetchInterval) ?? false
|
|
352
|
+
)
|
|
351
353
|
}
|
|
352
354
|
|
|
353
355
|
#updateRefetchInterval(nextInterval: number | false): void {
|
|
@@ -593,7 +595,7 @@ export class QueryObserver<
|
|
|
593
595
|
|
|
594
596
|
const includedProps = new Set(notifyOnChangeProps ?? this.#trackedProps)
|
|
595
597
|
|
|
596
|
-
if (this.options.
|
|
598
|
+
if (this.options.throwOnError) {
|
|
597
599
|
includedProps.add('error')
|
|
598
600
|
}
|
|
599
601
|
|
package/src/types.ts
CHANGED
|
@@ -154,7 +154,7 @@ export interface InfiniteQueryPageParamsOptions<
|
|
|
154
154
|
getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
export type
|
|
157
|
+
export type ThrowOnError<
|
|
158
158
|
TQueryFnData,
|
|
159
159
|
TError,
|
|
160
160
|
TQueryData,
|
|
@@ -202,7 +202,7 @@ export interface QueryObserverOptions<
|
|
|
202
202
|
| ((
|
|
203
203
|
data: TData | undefined,
|
|
204
204
|
query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,
|
|
205
|
-
) => number | false)
|
|
205
|
+
) => number | false | undefined)
|
|
206
206
|
/**
|
|
207
207
|
* If set to `true`, the query will continue to refetch while their tab/window is in the background.
|
|
208
208
|
* Defaults to `false`.
|
|
@@ -266,7 +266,7 @@ export interface QueryObserverOptions<
|
|
|
266
266
|
* If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).
|
|
267
267
|
* Defaults to `false`.
|
|
268
268
|
*/
|
|
269
|
-
|
|
269
|
+
throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>
|
|
270
270
|
/**
|
|
271
271
|
* This option can be used to transform or select a part of the data returned by the query function.
|
|
272
272
|
*/
|
|
@@ -297,7 +297,7 @@ export type DefaultedQueryObserverOptions<
|
|
|
297
297
|
TQueryKey extends QueryKey = QueryKey,
|
|
298
298
|
> = WithRequired<
|
|
299
299
|
QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,
|
|
300
|
-
'
|
|
300
|
+
'throwOnError' | 'refetchOnReconnect'
|
|
301
301
|
>
|
|
302
302
|
|
|
303
303
|
export interface InfiniteQueryObserverOptions<
|
|
@@ -333,7 +333,7 @@ export type DefaultedInfiniteQueryObserverOptions<
|
|
|
333
333
|
TQueryKey,
|
|
334
334
|
TPageParam
|
|
335
335
|
>,
|
|
336
|
-
'
|
|
336
|
+
'throwOnError' | 'refetchOnReconnect'
|
|
337
337
|
>
|
|
338
338
|
|
|
339
339
|
export interface FetchQueryOptions<
|
|
@@ -636,7 +636,7 @@ export interface MutationObserverOptions<
|
|
|
636
636
|
TVariables = void,
|
|
637
637
|
TContext = unknown,
|
|
638
638
|
> extends MutationOptions<TData, TError, TVariables, TContext> {
|
|
639
|
-
|
|
639
|
+
throwOnError?: boolean | ((error: TError) => boolean)
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
export interface MutateOptions<
|