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

QueryCacheConfig.md

19 lines1.3 KB

1---
2id: QueryCacheConfig
3title: QueryCacheConfig
4---
5​
6Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25)
7​
8Global callbacks that fire for every query handled by a `QueryCache`, regardless of which
9component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can
10override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these
11are fire-and-forget: their return value is not awaited before the query settles.
12​
13## Properties
14​
15| Property | Type | Description |
16| ------ | ------ | ------ |
17| <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. |
18| <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. |
19| <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. |