Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

QueryCacheConfig.md

21 lines1.4 KB

1---
2id: QueryCacheConfig
3title: QueryCacheConfig
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25)
9​
10Global callbacks that fire for every query handled by a `QueryCache`, regardless of which
11component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can
12override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these
13are fire-and-forget: their return value is not awaited before the query settles.
14​
15## Properties
16​
17| Property | Type | Description |
18| ------ | ------ | ------ |
19| <a id="property-onerror"></a> `onError?` | (`error`: `Error`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache encounters an error. |
20| <a id="property-onsettled"></a> `onSettled?` | (`data`: `unknown`, `error`: `Error` \| `null`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is settled, either successfully or with an error. |
21| <a id="property-onsuccess"></a> `onSuccess?` | (`data`: `unknown`, `query`: [`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\>) => `void` | Called when any query in the cache is successful. |