From 8a05d5a848dcfaae7bcf6bd7355ca5f34c83b95b Mon Sep 17 00:00:00 2001 From: vkpdeveloper Date: Thu, 22 Oct 2026 01:34:08 +0000 Subject: [PATCH] fix(query-core): honour fetchStatus filters in isFetching --- .changeset/great-ghosts-ring.md | 5 ++ .../angular/reference/classes/QueryClient.md | 77 ++++++++++--------- .../reference/functions/injectIsFetching.md | 8 +- .../lit/reference/classes/QueryClient.md | 77 ++++++++++--------- .../lit/reference/functions/useIsFetching.md | 9 ++- .../type-aliases/IsFetchingAccessor.md | 2 +- .../preact/reference/classes/QueryClient.md | 77 ++++++++++--------- .../reference/functions/useIsFetching.md | 8 +- .../react/reference/classes/QueryClient.md | 77 ++++++++++--------- .../reference/functions/useIsFetching.md | 8 +- .../solid/reference/classes/QueryClient.md | 77 ++++++++++--------- .../reference/functions/useIsFetching.md | 9 ++- .../svelte/reference/classes/QueryClient.md | 77 ++++++++++--------- .../reference/functions/useIsFetching.md | 8 +- .../vue/reference/classes/QueryClient.md | 29 +++---- .../vue/reference/functions/useIsFetching.md | 8 +- .../src/inject-is-fetching.ts | 8 +- packages/lit-query/src/useIsFetching.ts | 9 ++- packages/preact-query/src/useIsFetching.ts | 8 +- .../src/__tests__/queryClient.test.tsx | 60 +++++++++++++++ packages/query-core/src/queryClient.ts | 19 +++-- .../src/__tests__/useIsFetching.test.tsx | 39 ++++++++++ packages/react-query/src/useIsFetching.ts | 8 +- packages/solid-query/src/useIsFetching.ts | 7 +- .../svelte-query/src/useIsFetching.svelte.ts | 8 +- packages/vue-query/src/useIsFetching.ts | 8 +- 26 files changed, 424 insertions(+), 306 deletions(-) create mode 100644 .changeset/great-ghosts-ring.md diff --git a/.changeset/great-ghosts-ring.md b/.changeset/great-ghosts-ring.md new file mode 100644 index 00000000000..e325a3380d2 --- /dev/null +++ b/.changeset/great-ghosts-ring.md @@ -0,0 +1,5 @@ +--- +"@tanstack/query-core": patch +--- + +Honour explicit `fetchStatus` filters in `QueryClient.isFetching` and framework fetching counters. Passing `'paused'` or `'idle'` now counts queries in that status; omitted or `undefined` values still default to `'fetching'`. diff --git a/docs/framework/angular/reference/classes/QueryClient.md b/docs/framework/angular/reference/classes/QueryClient.md index 37864f12052..596cb65a878 100644 --- a/docs/framework/angular/reference/classes/QueryClient.md +++ b/docs/framework/angular/reference/classes/QueryClient.md @@ -53,7 +53,7 @@ Defined in: [packages/query-core/src/queryClient.ts:88](https://github.com/TanSt cancelQueries(filters?: QueryFilters, cancelOptions?: CancelOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:461](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L461) +Defined in: [packages/query-core/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L464) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -104,7 +104,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) clear(): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:1168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1168) +Defined in: [packages/query-core/src/queryClient.ts:1171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1171) Clears both the query cache and the mutation cache this client is connected to. @@ -129,7 +129,7 @@ queryClient.clear() defaultMutationOptions>(options?: T): T; ``` -Defined in: [packages/query-core/src/queryClient.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1143) +Defined in: [packages/query-core/src/queryClient.ts:1146](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1146) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then @@ -166,7 +166,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1054) +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the caller into their final, defaulted form: merging the client's own `defaultOptions.queries`, @@ -223,7 +223,7 @@ The defaulted options, with `queryHash` and dependent defaults (e.g. ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:809](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L809) +Defined in: [packages/query-core/src/queryClient.ts:812](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L812) Returns the cached data of an infinite query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -278,7 +278,7 @@ Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This ensureQueryData(options: EnsureQueryDataOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L207) +Defined in: [packages/query-core/src/queryClient.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L210) Returns the cached data of a query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -329,7 +329,7 @@ Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method fetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:753](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L753) +Defined in: [packages/query-core/src/queryClient.ts:756](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L756) Fetches and caches an infinite query, or returns its cached data if it isn't stale. @@ -383,7 +383,7 @@ Use queryClient.infiniteQuery(options) instead. This method will be removed in t fetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:647](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L647) +Defined in: [packages/query-core/src/queryClient.ts:650](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L650) Fetches and caches a query, or returns its cached data if it isn't stale. Unlike in observers, the fetch isn't retried unless `retry` is set. @@ -438,7 +438,7 @@ Use queryClient.query(options) instead. This method will be removed in the next getDefaultOptions(): DefaultOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:893](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L893) +Defined in: [packages/query-core/src/queryClient.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L896) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -466,7 +466,7 @@ const defaultOptions = queryClient.getDefaultOptions() getMutationCache(): MutationCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:877](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L877) +Defined in: [packages/query-core/src/queryClient.ts:880](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L880) Returns the mutation cache this client is connected to. @@ -494,7 +494,7 @@ const mutations = mutationCache.findAll({ status: 'pending' }) getMutationDefaults(mutationKey: readonly unknown[]): OmitKeyof, "mutationKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:1026](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1026) +Defined in: [packages/query-core/src/queryClient.ts:1029](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1029) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -529,7 +529,7 @@ const defaultOptions = queryClient.getMutationDefaults(['addPost']) getQueriesData = QueryFilters>(filters: TQueryFilters): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:253](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L253) +Defined in: [packages/query-core/src/queryClient.ts:256](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L256) Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. Only queries matching the given filters are returned; if none match, an empty array is @@ -583,7 +583,7 @@ const data = queryClient.getQueriesData({ queryKey: ['posts'] }) getQueryCache(): QueryCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:861](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L861) +Defined in: [packages/query-core/src/queryClient.ts:864](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L864) Returns the query cache this client is connected to. @@ -611,7 +611,7 @@ const queries = queryCache.findAll({ queryKey: ['posts'] }) getQueryData>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) +Defined in: [packages/query-core/src/queryClient.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L190) Imperative (non-reactive) way to retrieve data for a QueryKey. Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. @@ -659,7 +659,7 @@ The cached data for the query, or `undefined` if no query with this key has been getQueryDefaults(queryKey: readonly unknown[]): OmitKeyof, "queryKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L966) +Defined in: [packages/query-core/src/queryClient.ts:969](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L969) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -696,7 +696,7 @@ getQueryState, TQueryKey extends readonly unknown[] = readonly unknown[], TPageParam = unknown>(options: InfiniteQueryExecuteOptions): Promise[] ? InfiniteData : TData>; ``` -Defined in: [packages/query-core/src/queryClient.ts:722](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L722) +Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L725) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -822,7 +822,7 @@ try { invalidateQueries(filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:494](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L494) +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -874,11 +874,11 @@ await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' isFetching = QueryFilters>(filters?: TQueryFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) +Defined in: [packages/query-core/src/queryClient.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L152) -Returns the number of queries in the cache that are currently fetching, optionally -matching a set of filters. This includes background-fetching, loading new pages, and -loading more infinite query results. +Returns the number of queries in the cache matching a set of filters. By default, counts +fetching queries, including background-fetching, loading new pages, and loading more +infinite query results. #### Type Parameters @@ -892,14 +892,15 @@ loading more infinite query results. `TQueryFilters` -Narrows down which fetching queries are counted. Without filters, every -fetching query is counted. +Narrows down which queries are counted. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries +in that status instead. #### Returns `number` -The number of matching queries whose `fetchStatus` is `'fetching'`. +The number of matching queries with the requested `fetchStatus`. #### Example @@ -917,7 +918,7 @@ if (queryClient.isFetching()) { isMutating = MutationFilters>(filters?: TMutationFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) +Defined in: [packages/query-core/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L174) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -978,7 +979,7 @@ the shared listeners until the last one unmounts. prefetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:781](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L781) +Defined in: [packages/query-core/src/queryClient.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L784) Fetches and caches an infinite query like [QueryClient#fetchInfiniteQuery](#fetchinfinitequery), but ignores the result and any error. @@ -1032,7 +1033,7 @@ Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.ca prefetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:686](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L686) +Defined in: [packages/query-core/src/queryClient.ts:689](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L689) Fetches and caches a query like [QueryClient#fetchQuery](#fetchquery), but ignores the result and any error. @@ -1082,7 +1083,7 @@ Use queryClient.query(options) instead. You can swallow errors with `.catch(noop query(options: QueryExecuteOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L595) +Defined in: [packages/query-core/src/queryClient.ts:598](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L598) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1165,7 +1166,7 @@ try { refetchQueries(filters?: RefetchQueryFilters, options?: RefetchOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:535](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L535) +Defined in: [packages/query-core/src/queryClient.ts:538](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L538) Refetches queries matching the given filters, regardless of whether they are stale. Without filters, every query in the cache is refetched. Queries that are disabled, or static (only @@ -1218,7 +1219,7 @@ await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) removeQueries(filters?: QueryFilters): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) +Defined in: [packages/query-core/src/queryClient.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L400) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1258,7 +1259,7 @@ queryClient.removeQueries({ queryKey: ['posts'], exact: true }) resetQueries(filters?: QueryFilters, options?: ResetOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:422](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L422) +Defined in: [packages/query-core/src/queryClient.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L425) Resets queries matching the given filters back to their initial state (e.g. any `initialData`), notifying subscribers rather than removing them. Active queries among the @@ -1306,7 +1307,7 @@ await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) resumePausedMutations(): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:842](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L842) +Defined in: [packages/query-core/src/queryClient.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L845) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1334,7 +1335,7 @@ await queryClient.resumePausedMutations() setDefaultOptions(options: DefaultOptions): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L914) +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1376,7 +1377,7 @@ queryClient.setDefaultOptions({ setMutationDefaults(mutationKey: readonly unknown[], options: OmitKeyof, "mutationKey">): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:996](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L996) +Defined in: [packages/query-core/src/queryClient.ts:999](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L999) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1440,7 +1441,7 @@ setQueriesData = QueryFilt ): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L338) +Defined in: [packages/query-core/src/queryClient.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L341) Synchronous way to immediately update the cached data of multiple queries at once, using filters or partial query key matching. Only queries that already exist and match the given @@ -1507,7 +1508,7 @@ setQueryData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L285) +Defined in: [packages/query-core/src/queryClient.ts:288](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L288) Synchronous way to immediately update a query's cached data. If the updater (or the value passed) resolves to `undefined`, the cache is left untouched and no query is created; @@ -1578,7 +1579,7 @@ queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) setQueryDefaults(queryKey: readonly unknown[], options: Partial, "queryKey">>): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L934) +Defined in: [packages/query-core/src/queryClient.ts:937](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L937) Sets default options for queries whose query key partially matches the given `queryKey`. diff --git a/docs/framework/angular/reference/functions/injectIsFetching.md b/docs/framework/angular/reference/functions/injectIsFetching.md index 07ed5f886f6..39fa597f3af 100644 --- a/docs/framework/angular/reference/functions/injectIsFetching.md +++ b/docs/framework/angular/reference/functions/injectIsFetching.md @@ -12,7 +12,7 @@ function injectIsFetching(filters?: QueryFilters, options?: Defined in: [packages/angular-query-experimental/src/inject-is-fetching.ts:63](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L63) Injects a signal that tracks the number of queries that your application is loading or fetching in the -background (useful for app-wide loading indicators). +background by default (useful for app-wide loading indicators). ## Parameters @@ -20,7 +20,8 @@ background (useful for app-wide loading indicators). [`QueryFilters`](../interfaces/QueryFilters.md)\ -The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. +The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. @@ -53,8 +54,7 @@ Additional configuration `Signal`\<`number`\> -A `Signal` with the number of queries that your application is currently loading or fetching in -the background. +A `Signal` with the number of matching queries with the requested `fetchStatus`. ## Examples diff --git a/docs/framework/lit/reference/classes/QueryClient.md b/docs/framework/lit/reference/classes/QueryClient.md index 3523579eba5..27f3a01f99e 100644 --- a/docs/framework/lit/reference/classes/QueryClient.md +++ b/docs/framework/lit/reference/classes/QueryClient.md @@ -53,7 +53,7 @@ Defined in: [packages/query-core/src/queryClient.ts:88](https://github.com/TanSt cancelQueries(filters?: QueryFilters, cancelOptions?: CancelOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:461](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L461) +Defined in: [packages/query-core/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L464) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -104,7 +104,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) clear(): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:1168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1168) +Defined in: [packages/query-core/src/queryClient.ts:1171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1171) Clears both the query cache and the mutation cache this client is connected to. @@ -129,7 +129,7 @@ queryClient.clear() defaultMutationOptions>(options?: T): T; ``` -Defined in: [packages/query-core/src/queryClient.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1143) +Defined in: [packages/query-core/src/queryClient.ts:1146](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1146) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then @@ -166,7 +166,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1054) +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the caller into their final, defaulted form: merging the client's own `defaultOptions.queries`, @@ -223,7 +223,7 @@ The defaulted options, with `queryHash` and dependent defaults (e.g. ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:809](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L809) +Defined in: [packages/query-core/src/queryClient.ts:812](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L812) Returns the cached data of an infinite query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -278,7 +278,7 @@ Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This ensureQueryData(options: EnsureQueryDataOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L207) +Defined in: [packages/query-core/src/queryClient.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L210) Returns the cached data of a query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -329,7 +329,7 @@ Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method fetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:753](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L753) +Defined in: [packages/query-core/src/queryClient.ts:756](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L756) Fetches and caches an infinite query, or returns its cached data if it isn't stale. @@ -383,7 +383,7 @@ Use queryClient.infiniteQuery(options) instead. This method will be removed in t fetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:647](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L647) +Defined in: [packages/query-core/src/queryClient.ts:650](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L650) Fetches and caches a query, or returns its cached data if it isn't stale. Unlike in observers, the fetch isn't retried unless `retry` is set. @@ -438,7 +438,7 @@ Use queryClient.query(options) instead. This method will be removed in the next getDefaultOptions(): DefaultOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:893](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L893) +Defined in: [packages/query-core/src/queryClient.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L896) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -466,7 +466,7 @@ const defaultOptions = queryClient.getDefaultOptions() getMutationCache(): MutationCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:877](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L877) +Defined in: [packages/query-core/src/queryClient.ts:880](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L880) Returns the mutation cache this client is connected to. @@ -494,7 +494,7 @@ const mutations = mutationCache.findAll({ status: 'pending' }) getMutationDefaults(mutationKey: readonly unknown[]): OmitKeyof, "mutationKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:1026](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1026) +Defined in: [packages/query-core/src/queryClient.ts:1029](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1029) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -529,7 +529,7 @@ const defaultOptions = queryClient.getMutationDefaults(['addPost']) getQueriesData = QueryFilters>(filters: TQueryFilters): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:253](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L253) +Defined in: [packages/query-core/src/queryClient.ts:256](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L256) Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. Only queries matching the given filters are returned; if none match, an empty array is @@ -583,7 +583,7 @@ const data = queryClient.getQueriesData({ queryKey: ['posts'] }) getQueryCache(): QueryCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:861](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L861) +Defined in: [packages/query-core/src/queryClient.ts:864](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L864) Returns the query cache this client is connected to. @@ -611,7 +611,7 @@ const queries = queryCache.findAll({ queryKey: ['posts'] }) getQueryData>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) +Defined in: [packages/query-core/src/queryClient.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L190) Imperative (non-reactive) way to retrieve data for a QueryKey. Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. @@ -659,7 +659,7 @@ The cached data for the query, or `undefined` if no query with this key has been getQueryDefaults(queryKey: readonly unknown[]): OmitKeyof, "queryKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L966) +Defined in: [packages/query-core/src/queryClient.ts:969](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L969) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -696,7 +696,7 @@ getQueryState, TQueryKey extends readonly unknown[] = readonly unknown[], TPageParam = unknown>(options: InfiniteQueryExecuteOptions): Promise[] ? InfiniteData : TData>; ``` -Defined in: [packages/query-core/src/queryClient.ts:722](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L722) +Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L725) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -822,7 +822,7 @@ try { invalidateQueries(filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:494](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L494) +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -874,11 +874,11 @@ await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' isFetching = QueryFilters>(filters?: TQueryFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) +Defined in: [packages/query-core/src/queryClient.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L152) -Returns the number of queries in the cache that are currently fetching, optionally -matching a set of filters. This includes background-fetching, loading new pages, and -loading more infinite query results. +Returns the number of queries in the cache matching a set of filters. By default, counts +fetching queries, including background-fetching, loading new pages, and loading more +infinite query results. #### Type Parameters @@ -892,14 +892,15 @@ loading more infinite query results. `TQueryFilters` -Narrows down which fetching queries are counted. Without filters, every -fetching query is counted. +Narrows down which queries are counted. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries +in that status instead. #### Returns `number` -The number of matching queries whose `fetchStatus` is `'fetching'`. +The number of matching queries with the requested `fetchStatus`. #### Example @@ -917,7 +918,7 @@ if (queryClient.isFetching()) { isMutating = MutationFilters>(filters?: TMutationFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) +Defined in: [packages/query-core/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L174) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -978,7 +979,7 @@ the shared listeners until the last one unmounts. prefetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:781](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L781) +Defined in: [packages/query-core/src/queryClient.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L784) Fetches and caches an infinite query like [QueryClient#fetchInfiniteQuery](#fetchinfinitequery), but ignores the result and any error. @@ -1032,7 +1033,7 @@ Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.ca prefetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:686](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L686) +Defined in: [packages/query-core/src/queryClient.ts:689](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L689) Fetches and caches a query like [QueryClient#fetchQuery](#fetchquery), but ignores the result and any error. @@ -1082,7 +1083,7 @@ Use queryClient.query(options) instead. You can swallow errors with `.catch(noop query(options: QueryExecuteOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L595) +Defined in: [packages/query-core/src/queryClient.ts:598](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L598) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1165,7 +1166,7 @@ try { refetchQueries(filters?: RefetchQueryFilters, options?: RefetchOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:535](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L535) +Defined in: [packages/query-core/src/queryClient.ts:538](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L538) Refetches queries matching the given filters, regardless of whether they are stale. Without filters, every query in the cache is refetched. Queries that are disabled, or static (only @@ -1218,7 +1219,7 @@ await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) removeQueries(filters?: QueryFilters): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) +Defined in: [packages/query-core/src/queryClient.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L400) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1258,7 +1259,7 @@ queryClient.removeQueries({ queryKey: ['posts'], exact: true }) resetQueries(filters?: QueryFilters, options?: ResetOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:422](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L422) +Defined in: [packages/query-core/src/queryClient.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L425) Resets queries matching the given filters back to their initial state (e.g. any `initialData`), notifying subscribers rather than removing them. Active queries among the @@ -1306,7 +1307,7 @@ await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) resumePausedMutations(): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:842](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L842) +Defined in: [packages/query-core/src/queryClient.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L845) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1334,7 +1335,7 @@ await queryClient.resumePausedMutations() setDefaultOptions(options: DefaultOptions): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L914) +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1376,7 +1377,7 @@ queryClient.setDefaultOptions({ setMutationDefaults(mutationKey: readonly unknown[], options: OmitKeyof, "mutationKey">): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:996](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L996) +Defined in: [packages/query-core/src/queryClient.ts:999](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L999) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1440,7 +1441,7 @@ setQueriesData = QueryFilt ): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L338) +Defined in: [packages/query-core/src/queryClient.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L341) Synchronous way to immediately update the cached data of multiple queries at once, using filters or partial query key matching. Only queries that already exist and match the given @@ -1507,7 +1508,7 @@ setQueryData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L285) +Defined in: [packages/query-core/src/queryClient.ts:288](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L288) Synchronous way to immediately update a query's cached data. If the updater (or the value passed) resolves to `undefined`, the cache is left untouched and no query is created; @@ -1578,7 +1579,7 @@ queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) setQueryDefaults(queryKey: readonly unknown[], options: Partial, "queryKey">>): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L934) +Defined in: [packages/query-core/src/queryClient.ts:937](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L937) Sets default options for queries whose query key partially matches the given `queryKey`. diff --git a/docs/framework/lit/reference/functions/useIsFetching.md b/docs/framework/lit/reference/functions/useIsFetching.md index 1c7b2d02b0a..584105a372a 100644 --- a/docs/framework/lit/reference/functions/useIsFetching.md +++ b/docs/framework/lit/reference/functions/useIsFetching.md @@ -13,10 +13,10 @@ function useIsFetching( ): IsFetchingAccessor; ``` -Defined in: [packages/lit-query/src/useIsFetching.ts:141](https://github.com/TanStack/query/blob/main/packages/lit-query/src/useIsFetching.ts#L141) +Defined in: [packages/lit-query/src/useIsFetching.ts:142](https://github.com/TanStack/query/blob/main/packages/lit-query/src/useIsFetching.ts#L142) Creates a Lit reactive controller that tracks how many matching queries are -currently fetching. +currently fetching by default. When `filters` is a function, it is re-read during host updates so the count can follow reactive host state. If `queryClient` is omitted, the controller @@ -35,7 +35,8 @@ subscription. [`Accessor`](../type-aliases/Accessor.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` -Query filters, or a getter that returns query filters. +Query filters, or a getter that returns query filters. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. @@ -54,7 +55,7 @@ controllers that should not resolve a client from Lit context. [`IsFetchingAccessor`](../type-aliases/IsFetchingAccessor.md) -An accessor for the current number of matching fetching queries. +An accessor for the number of matching queries with the requested `fetchStatus`. ## Example diff --git a/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md b/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md index 41f363a9485..bfd0484177b 100644 --- a/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md +++ b/docs/framework/lit/reference/type-aliases/IsFetchingAccessor.md @@ -14,7 +14,7 @@ Defined in: [packages/lit-query/src/useIsFetching.ts:13](https://github.com/TanS Accessor returned by `useIsFetching`. Call the accessor or read its `current` property to get the number of -currently fetching queries that match the filters. +queries that match the filters, defaulting to currently fetching queries. ## Type Declaration diff --git a/docs/framework/preact/reference/classes/QueryClient.md b/docs/framework/preact/reference/classes/QueryClient.md index 37864f12052..596cb65a878 100644 --- a/docs/framework/preact/reference/classes/QueryClient.md +++ b/docs/framework/preact/reference/classes/QueryClient.md @@ -53,7 +53,7 @@ Defined in: [packages/query-core/src/queryClient.ts:88](https://github.com/TanSt cancelQueries(filters?: QueryFilters, cancelOptions?: CancelOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:461](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L461) +Defined in: [packages/query-core/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L464) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -104,7 +104,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) clear(): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:1168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1168) +Defined in: [packages/query-core/src/queryClient.ts:1171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1171) Clears both the query cache and the mutation cache this client is connected to. @@ -129,7 +129,7 @@ queryClient.clear() defaultMutationOptions>(options?: T): T; ``` -Defined in: [packages/query-core/src/queryClient.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1143) +Defined in: [packages/query-core/src/queryClient.ts:1146](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1146) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then @@ -166,7 +166,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1054) +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the caller into their final, defaulted form: merging the client's own `defaultOptions.queries`, @@ -223,7 +223,7 @@ The defaulted options, with `queryHash` and dependent defaults (e.g. ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:809](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L809) +Defined in: [packages/query-core/src/queryClient.ts:812](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L812) Returns the cached data of an infinite query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -278,7 +278,7 @@ Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This ensureQueryData(options: EnsureQueryDataOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L207) +Defined in: [packages/query-core/src/queryClient.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L210) Returns the cached data of a query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -329,7 +329,7 @@ Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method fetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:753](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L753) +Defined in: [packages/query-core/src/queryClient.ts:756](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L756) Fetches and caches an infinite query, or returns its cached data if it isn't stale. @@ -383,7 +383,7 @@ Use queryClient.infiniteQuery(options) instead. This method will be removed in t fetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:647](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L647) +Defined in: [packages/query-core/src/queryClient.ts:650](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L650) Fetches and caches a query, or returns its cached data if it isn't stale. Unlike in observers, the fetch isn't retried unless `retry` is set. @@ -438,7 +438,7 @@ Use queryClient.query(options) instead. This method will be removed in the next getDefaultOptions(): DefaultOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:893](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L893) +Defined in: [packages/query-core/src/queryClient.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L896) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -466,7 +466,7 @@ const defaultOptions = queryClient.getDefaultOptions() getMutationCache(): MutationCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:877](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L877) +Defined in: [packages/query-core/src/queryClient.ts:880](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L880) Returns the mutation cache this client is connected to. @@ -494,7 +494,7 @@ const mutations = mutationCache.findAll({ status: 'pending' }) getMutationDefaults(mutationKey: readonly unknown[]): OmitKeyof, "mutationKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:1026](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1026) +Defined in: [packages/query-core/src/queryClient.ts:1029](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1029) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -529,7 +529,7 @@ const defaultOptions = queryClient.getMutationDefaults(['addPost']) getQueriesData = QueryFilters>(filters: TQueryFilters): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:253](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L253) +Defined in: [packages/query-core/src/queryClient.ts:256](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L256) Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. Only queries matching the given filters are returned; if none match, an empty array is @@ -583,7 +583,7 @@ const data = queryClient.getQueriesData({ queryKey: ['posts'] }) getQueryCache(): QueryCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:861](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L861) +Defined in: [packages/query-core/src/queryClient.ts:864](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L864) Returns the query cache this client is connected to. @@ -611,7 +611,7 @@ const queries = queryCache.findAll({ queryKey: ['posts'] }) getQueryData>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) +Defined in: [packages/query-core/src/queryClient.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L190) Imperative (non-reactive) way to retrieve data for a QueryKey. Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. @@ -659,7 +659,7 @@ The cached data for the query, or `undefined` if no query with this key has been getQueryDefaults(queryKey: readonly unknown[]): OmitKeyof, "queryKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L966) +Defined in: [packages/query-core/src/queryClient.ts:969](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L969) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -696,7 +696,7 @@ getQueryState, TQueryKey extends readonly unknown[] = readonly unknown[], TPageParam = unknown>(options: InfiniteQueryExecuteOptions): Promise[] ? InfiniteData : TData>; ``` -Defined in: [packages/query-core/src/queryClient.ts:722](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L722) +Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L725) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -822,7 +822,7 @@ try { invalidateQueries(filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:494](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L494) +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -874,11 +874,11 @@ await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' isFetching = QueryFilters>(filters?: TQueryFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) +Defined in: [packages/query-core/src/queryClient.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L152) -Returns the number of queries in the cache that are currently fetching, optionally -matching a set of filters. This includes background-fetching, loading new pages, and -loading more infinite query results. +Returns the number of queries in the cache matching a set of filters. By default, counts +fetching queries, including background-fetching, loading new pages, and loading more +infinite query results. #### Type Parameters @@ -892,14 +892,15 @@ loading more infinite query results. `TQueryFilters` -Narrows down which fetching queries are counted. Without filters, every -fetching query is counted. +Narrows down which queries are counted. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries +in that status instead. #### Returns `number` -The number of matching queries whose `fetchStatus` is `'fetching'`. +The number of matching queries with the requested `fetchStatus`. #### Example @@ -917,7 +918,7 @@ if (queryClient.isFetching()) { isMutating = MutationFilters>(filters?: TMutationFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) +Defined in: [packages/query-core/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L174) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -978,7 +979,7 @@ the shared listeners until the last one unmounts. prefetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:781](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L781) +Defined in: [packages/query-core/src/queryClient.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L784) Fetches and caches an infinite query like [QueryClient#fetchInfiniteQuery](#fetchinfinitequery), but ignores the result and any error. @@ -1032,7 +1033,7 @@ Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.ca prefetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:686](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L686) +Defined in: [packages/query-core/src/queryClient.ts:689](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L689) Fetches and caches a query like [QueryClient#fetchQuery](#fetchquery), but ignores the result and any error. @@ -1082,7 +1083,7 @@ Use queryClient.query(options) instead. You can swallow errors with `.catch(noop query(options: QueryExecuteOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L595) +Defined in: [packages/query-core/src/queryClient.ts:598](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L598) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1165,7 +1166,7 @@ try { refetchQueries(filters?: RefetchQueryFilters, options?: RefetchOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:535](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L535) +Defined in: [packages/query-core/src/queryClient.ts:538](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L538) Refetches queries matching the given filters, regardless of whether they are stale. Without filters, every query in the cache is refetched. Queries that are disabled, or static (only @@ -1218,7 +1219,7 @@ await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) removeQueries(filters?: QueryFilters): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) +Defined in: [packages/query-core/src/queryClient.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L400) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1258,7 +1259,7 @@ queryClient.removeQueries({ queryKey: ['posts'], exact: true }) resetQueries(filters?: QueryFilters, options?: ResetOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:422](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L422) +Defined in: [packages/query-core/src/queryClient.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L425) Resets queries matching the given filters back to their initial state (e.g. any `initialData`), notifying subscribers rather than removing them. Active queries among the @@ -1306,7 +1307,7 @@ await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) resumePausedMutations(): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:842](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L842) +Defined in: [packages/query-core/src/queryClient.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L845) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1334,7 +1335,7 @@ await queryClient.resumePausedMutations() setDefaultOptions(options: DefaultOptions): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L914) +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1376,7 +1377,7 @@ queryClient.setDefaultOptions({ setMutationDefaults(mutationKey: readonly unknown[], options: OmitKeyof, "mutationKey">): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:996](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L996) +Defined in: [packages/query-core/src/queryClient.ts:999](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L999) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1440,7 +1441,7 @@ setQueriesData = QueryFilt ): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L338) +Defined in: [packages/query-core/src/queryClient.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L341) Synchronous way to immediately update the cached data of multiple queries at once, using filters or partial query key matching. Only queries that already exist and match the given @@ -1507,7 +1508,7 @@ setQueryData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L285) +Defined in: [packages/query-core/src/queryClient.ts:288](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L288) Synchronous way to immediately update a query's cached data. If the updater (or the value passed) resolves to `undefined`, the cache is left untouched and no query is created; @@ -1578,7 +1579,7 @@ queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) setQueryDefaults(queryKey: readonly unknown[], options: Partial, "queryKey">>): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L934) +Defined in: [packages/query-core/src/queryClient.ts:937](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L937) Sets default options for queries whose query key partially matches the given `queryKey`. diff --git a/docs/framework/preact/reference/functions/useIsFetching.md b/docs/framework/preact/reference/functions/useIsFetching.md index 27ba8efc488..ff4fed6cf84 100644 --- a/docs/framework/preact/reference/functions/useIsFetching.md +++ b/docs/framework/preact/reference/functions/useIsFetching.md @@ -12,7 +12,7 @@ function useIsFetching(filters?: QueryFilters, queryClient?: Defined in: [packages/preact-query/src/useIsFetching.ts:41](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useIsFetching.ts#L41) The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching in -the background (useful for app-wide loading indicators). +the background by default (useful for app-wide loading indicators). ## Parameters @@ -20,7 +20,8 @@ the background (useful for app-wide loading indicators). [`QueryFilters`](../interfaces/QueryFilters.md)\ -The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. +The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. @@ -46,8 +47,7 @@ be used. `number` -Will be the `number` of the queries that your application is currently loading or fetching in the -background. +The `number` of matching queries with the requested `fetchStatus`. ## Examples diff --git a/docs/framework/react/reference/classes/QueryClient.md b/docs/framework/react/reference/classes/QueryClient.md index f24d3dd2431..9a8aa478e77 100644 --- a/docs/framework/react/reference/classes/QueryClient.md +++ b/docs/framework/react/reference/classes/QueryClient.md @@ -56,7 +56,7 @@ Defined in: [packages/query-core/src/queryClient.ts:88](https://github.com/TanSt cancelQueries(filters?: QueryFilters, cancelOptions?: CancelOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:461](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L461) +Defined in: [packages/query-core/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L464) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -107,7 +107,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) clear(): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:1168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1168) +Defined in: [packages/query-core/src/queryClient.ts:1171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1171) Clears both the query cache and the mutation cache this client is connected to. @@ -132,7 +132,7 @@ queryClient.clear() defaultMutationOptions>(options?: T): T; ``` -Defined in: [packages/query-core/src/queryClient.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1143) +Defined in: [packages/query-core/src/queryClient.ts:1146](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1146) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then @@ -169,7 +169,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1054) +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the caller into their final, defaulted form: merging the client's own `defaultOptions.queries`, @@ -226,7 +226,7 @@ The defaulted options, with `queryHash` and dependent defaults (e.g. ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:809](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L809) +Defined in: [packages/query-core/src/queryClient.ts:812](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L812) Returns the cached data of an infinite query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -281,7 +281,7 @@ Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This ensureQueryData(options: EnsureQueryDataOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L207) +Defined in: [packages/query-core/src/queryClient.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L210) Returns the cached data of a query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -332,7 +332,7 @@ Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method fetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:753](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L753) +Defined in: [packages/query-core/src/queryClient.ts:756](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L756) Fetches and caches an infinite query, or returns its cached data if it isn't stale. @@ -386,7 +386,7 @@ Use queryClient.infiniteQuery(options) instead. This method will be removed in t fetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:647](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L647) +Defined in: [packages/query-core/src/queryClient.ts:650](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L650) Fetches and caches a query, or returns its cached data if it isn't stale. Unlike in observers, the fetch isn't retried unless `retry` is set. @@ -441,7 +441,7 @@ Use queryClient.query(options) instead. This method will be removed in the next getDefaultOptions(): DefaultOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:893](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L893) +Defined in: [packages/query-core/src/queryClient.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L896) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -469,7 +469,7 @@ const defaultOptions = queryClient.getDefaultOptions() getMutationCache(): MutationCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:877](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L877) +Defined in: [packages/query-core/src/queryClient.ts:880](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L880) Returns the mutation cache this client is connected to. @@ -497,7 +497,7 @@ const mutations = mutationCache.findAll({ status: 'pending' }) getMutationDefaults(mutationKey: readonly unknown[]): OmitKeyof, "mutationKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:1026](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1026) +Defined in: [packages/query-core/src/queryClient.ts:1029](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1029) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -532,7 +532,7 @@ const defaultOptions = queryClient.getMutationDefaults(['addPost']) getQueriesData = QueryFilters>(filters: TQueryFilters): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:253](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L253) +Defined in: [packages/query-core/src/queryClient.ts:256](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L256) Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. Only queries matching the given filters are returned; if none match, an empty array is @@ -586,7 +586,7 @@ const data = queryClient.getQueriesData({ queryKey: ['posts'] }) getQueryCache(): QueryCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:861](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L861) +Defined in: [packages/query-core/src/queryClient.ts:864](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L864) Returns the query cache this client is connected to. @@ -614,7 +614,7 @@ const queries = queryCache.findAll({ queryKey: ['posts'] }) getQueryData>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) +Defined in: [packages/query-core/src/queryClient.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L190) Imperative (non-reactive) way to retrieve data for a QueryKey. Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. @@ -662,7 +662,7 @@ The cached data for the query, or `undefined` if no query with this key has been getQueryDefaults(queryKey: readonly unknown[]): OmitKeyof, "queryKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L966) +Defined in: [packages/query-core/src/queryClient.ts:969](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L969) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -699,7 +699,7 @@ getQueryState, TQueryKey extends readonly unknown[] = readonly unknown[], TPageParam = unknown>(options: InfiniteQueryExecuteOptions): Promise[] ? InfiniteData : TData>; ``` -Defined in: [packages/query-core/src/queryClient.ts:722](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L722) +Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L725) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -825,7 +825,7 @@ try { invalidateQueries(filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:494](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L494) +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -877,11 +877,11 @@ await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' isFetching = QueryFilters>(filters?: TQueryFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) +Defined in: [packages/query-core/src/queryClient.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L152) -Returns the number of queries in the cache that are currently fetching, optionally -matching a set of filters. This includes background-fetching, loading new pages, and -loading more infinite query results. +Returns the number of queries in the cache matching a set of filters. By default, counts +fetching queries, including background-fetching, loading new pages, and loading more +infinite query results. #### Type Parameters @@ -895,14 +895,15 @@ loading more infinite query results. `TQueryFilters` -Narrows down which fetching queries are counted. Without filters, every -fetching query is counted. +Narrows down which queries are counted. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries +in that status instead. #### Returns `number` -The number of matching queries whose `fetchStatus` is `'fetching'`. +The number of matching queries with the requested `fetchStatus`. #### Example @@ -920,7 +921,7 @@ if (queryClient.isFetching()) { isMutating = MutationFilters>(filters?: TMutationFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) +Defined in: [packages/query-core/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L174) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -981,7 +982,7 @@ the shared listeners until the last one unmounts. prefetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:781](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L781) +Defined in: [packages/query-core/src/queryClient.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L784) Fetches and caches an infinite query like [QueryClient#fetchInfiniteQuery](#fetchinfinitequery), but ignores the result and any error. @@ -1035,7 +1036,7 @@ Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.ca prefetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:686](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L686) +Defined in: [packages/query-core/src/queryClient.ts:689](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L689) Fetches and caches a query like [QueryClient#fetchQuery](#fetchquery), but ignores the result and any error. @@ -1085,7 +1086,7 @@ Use queryClient.query(options) instead. You can swallow errors with `.catch(noop query(options: QueryExecuteOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L595) +Defined in: [packages/query-core/src/queryClient.ts:598](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L598) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1168,7 +1169,7 @@ try { refetchQueries(filters?: RefetchQueryFilters, options?: RefetchOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:535](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L535) +Defined in: [packages/query-core/src/queryClient.ts:538](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L538) Refetches queries matching the given filters, regardless of whether they are stale. Without filters, every query in the cache is refetched. Queries that are disabled, or static (only @@ -1221,7 +1222,7 @@ await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) removeQueries(filters?: QueryFilters): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) +Defined in: [packages/query-core/src/queryClient.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L400) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1261,7 +1262,7 @@ queryClient.removeQueries({ queryKey: ['posts'], exact: true }) resetQueries(filters?: QueryFilters, options?: ResetOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:422](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L422) +Defined in: [packages/query-core/src/queryClient.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L425) Resets queries matching the given filters back to their initial state (e.g. any `initialData`), notifying subscribers rather than removing them. Active queries among the @@ -1309,7 +1310,7 @@ await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) resumePausedMutations(): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:842](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L842) +Defined in: [packages/query-core/src/queryClient.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L845) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1337,7 +1338,7 @@ await queryClient.resumePausedMutations() setDefaultOptions(options: DefaultOptions): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L914) +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1379,7 +1380,7 @@ queryClient.setDefaultOptions({ setMutationDefaults(mutationKey: readonly unknown[], options: OmitKeyof, "mutationKey">): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:996](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L996) +Defined in: [packages/query-core/src/queryClient.ts:999](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L999) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1443,7 +1444,7 @@ setQueriesData = QueryFilt ): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L338) +Defined in: [packages/query-core/src/queryClient.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L341) Synchronous way to immediately update the cached data of multiple queries at once, using filters or partial query key matching. Only queries that already exist and match the given @@ -1510,7 +1511,7 @@ setQueryData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L285) +Defined in: [packages/query-core/src/queryClient.ts:288](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L288) Synchronous way to immediately update a query's cached data. If the updater (or the value passed) resolves to `undefined`, the cache is left untouched and no query is created; @@ -1581,7 +1582,7 @@ queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) setQueryDefaults(queryKey: readonly unknown[], options: Partial, "queryKey">>): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L934) +Defined in: [packages/query-core/src/queryClient.ts:937](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L937) Sets default options for queries whose query key partially matches the given `queryKey`. diff --git a/docs/framework/react/reference/functions/useIsFetching.md b/docs/framework/react/reference/functions/useIsFetching.md index 10f947a98c0..5230cc0dd5c 100644 --- a/docs/framework/react/reference/functions/useIsFetching.md +++ b/docs/framework/react/reference/functions/useIsFetching.md @@ -14,7 +14,7 @@ function useIsFetching(filters?: QueryFilters, queryClient?: Defined in: [packages/react-query/src/useIsFetching.ts:41](https://github.com/TanStack/query/blob/main/packages/react-query/src/useIsFetching.ts#L41) The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching in -the background (useful for app-wide loading indicators). +the background by default (useful for app-wide loading indicators). ## Parameters @@ -22,7 +22,8 @@ the background (useful for app-wide loading indicators). [`QueryFilters`](../interfaces/QueryFilters.md)\ -The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. +The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. @@ -48,8 +49,7 @@ be used. `number` -Will be the `number` of the queries that your application is currently loading or fetching in the -background. +The `number` of matching queries with the requested `fetchStatus`. ## Examples diff --git a/docs/framework/solid/reference/classes/QueryClient.md b/docs/framework/solid/reference/classes/QueryClient.md index 6e9445ed7bc..644da4f01ba 100644 --- a/docs/framework/solid/reference/classes/QueryClient.md +++ b/docs/framework/solid/reference/classes/QueryClient.md @@ -48,7 +48,7 @@ QueryCoreClient.constructor cancelQueries(filters?: QueryFilters, cancelOptions?: CancelOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:461](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L461) +Defined in: [packages/query-core/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L464) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -105,7 +105,7 @@ QueryCoreClient.cancelQueries clear(): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:1168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1168) +Defined in: [packages/query-core/src/queryClient.ts:1171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1171) Clears both the query cache and the mutation cache this client is connected to. @@ -136,7 +136,7 @@ QueryCoreClient.clear defaultMutationOptions>(options?: T): T; ``` -Defined in: [packages/query-core/src/queryClient.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1143) +Defined in: [packages/query-core/src/queryClient.ts:1146](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1146) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then @@ -179,7 +179,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1054) +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the caller into their final, defaulted form: merging the client's own `defaultOptions.queries`, @@ -242,7 +242,7 @@ QueryCoreClient.defaultQueryOptions ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:809](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L809) +Defined in: [packages/query-core/src/queryClient.ts:812](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L812) Returns the cached data of an infinite query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -303,7 +303,7 @@ QueryCoreClient.ensureInfiniteQueryData ensureQueryData(options: EnsureQueryDataOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L207) +Defined in: [packages/query-core/src/queryClient.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L210) Returns the cached data of a query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -360,7 +360,7 @@ QueryCoreClient.ensureQueryData fetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:753](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L753) +Defined in: [packages/query-core/src/queryClient.ts:756](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L756) Fetches and caches an infinite query, or returns its cached data if it isn't stale. @@ -420,7 +420,7 @@ QueryCoreClient.fetchInfiniteQuery fetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:647](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L647) +Defined in: [packages/query-core/src/queryClient.ts:650](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L650) Fetches and caches a query, or returns its cached data if it isn't stale. Unlike in observers, the fetch isn't retried unless `retry` is set. @@ -481,7 +481,7 @@ QueryCoreClient.fetchQuery getDefaultOptions(): DefaultOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:893](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L893) +Defined in: [packages/query-core/src/queryClient.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L896) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -515,7 +515,7 @@ QueryCoreClient.getDefaultOptions getMutationCache(): MutationCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:877](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L877) +Defined in: [packages/query-core/src/queryClient.ts:880](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L880) Returns the mutation cache this client is connected to. @@ -549,7 +549,7 @@ QueryCoreClient.getMutationCache getMutationDefaults(mutationKey: readonly unknown[]): OmitKeyof, "mutationKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:1026](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1026) +Defined in: [packages/query-core/src/queryClient.ts:1029](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1029) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -590,7 +590,7 @@ QueryCoreClient.getMutationDefaults getQueriesData = QueryFilters>(filters: TQueryFilters): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:253](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L253) +Defined in: [packages/query-core/src/queryClient.ts:256](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L256) Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. Only queries matching the given filters are returned; if none match, an empty array is @@ -650,7 +650,7 @@ QueryCoreClient.getQueriesData getQueryCache(): QueryCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:861](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L861) +Defined in: [packages/query-core/src/queryClient.ts:864](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L864) Returns the query cache this client is connected to. @@ -684,7 +684,7 @@ QueryCoreClient.getQueryCache getQueryData>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) +Defined in: [packages/query-core/src/queryClient.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L190) Imperative (non-reactive) way to retrieve data for a QueryKey. Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. @@ -738,7 +738,7 @@ QueryCoreClient.getQueryData getQueryDefaults(queryKey: readonly unknown[]): OmitKeyof, "queryKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L966) +Defined in: [packages/query-core/src/queryClient.ts:969](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L969) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -781,7 +781,7 @@ getQueryState, TQueryKey extends readonly unknown[] = readonly unknown[], TPageParam = unknown>(options: InfiniteQueryExecuteOptions): Promise[] ? InfiniteData : TData>; ``` -Defined in: [packages/query-core/src/queryClient.ts:722](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L722) +Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L725) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -919,7 +919,7 @@ QueryCoreClient.infiniteQuery invalidateQueries(filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:494](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L494) +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -977,11 +977,11 @@ QueryCoreClient.invalidateQueries isFetching = QueryFilters>(filters?: TQueryFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) +Defined in: [packages/query-core/src/queryClient.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L152) -Returns the number of queries in the cache that are currently fetching, optionally -matching a set of filters. This includes background-fetching, loading new pages, and -loading more infinite query results. +Returns the number of queries in the cache matching a set of filters. By default, counts +fetching queries, including background-fetching, loading new pages, and loading more +infinite query results. #### Type Parameters @@ -995,14 +995,15 @@ loading more infinite query results. `TQueryFilters` -Narrows down which fetching queries are counted. Without filters, every -fetching query is counted. +Narrows down which queries are counted. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries +in that status instead. #### Returns `number` -The number of matching queries whose `fetchStatus` is `'fetching'`. +The number of matching queries with the requested `fetchStatus`. #### Example @@ -1026,7 +1027,7 @@ QueryCoreClient.isFetching isMutating = MutationFilters>(filters?: TMutationFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) +Defined in: [packages/query-core/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L174) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -1099,7 +1100,7 @@ QueryCoreClient.mount prefetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:781](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L781) +Defined in: [packages/query-core/src/queryClient.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L784) Fetches and caches an infinite query like [QueryClient#fetchInfiniteQuery](#fetchinfinitequery), but ignores the result and any error. @@ -1159,7 +1160,7 @@ QueryCoreClient.prefetchInfiniteQuery prefetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:686](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L686) +Defined in: [packages/query-core/src/queryClient.ts:689](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L689) Fetches and caches a query like [QueryClient#fetchQuery](#fetchquery), but ignores the result and any error. @@ -1215,7 +1216,7 @@ QueryCoreClient.prefetchQuery query(options: QueryExecuteOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L595) +Defined in: [packages/query-core/src/queryClient.ts:598](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L598) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1304,7 +1305,7 @@ QueryCoreClient.query refetchQueries(filters?: RefetchQueryFilters, options?: RefetchOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:535](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L535) +Defined in: [packages/query-core/src/queryClient.ts:538](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L538) Refetches queries matching the given filters, regardless of whether they are stale. Without filters, every query in the cache is refetched. Queries that are disabled, or static (only @@ -1363,7 +1364,7 @@ QueryCoreClient.refetchQueries removeQueries(filters?: QueryFilters): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) +Defined in: [packages/query-core/src/queryClient.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L400) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1409,7 +1410,7 @@ QueryCoreClient.removeQueries resetQueries(filters?: QueryFilters, options?: ResetOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:422](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L422) +Defined in: [packages/query-core/src/queryClient.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L425) Resets queries matching the given filters back to their initial state (e.g. any `initialData`), notifying subscribers rather than removing them. Active queries among the @@ -1463,7 +1464,7 @@ QueryCoreClient.resetQueries resumePausedMutations(): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:842](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L842) +Defined in: [packages/query-core/src/queryClient.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L845) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1497,7 +1498,7 @@ QueryCoreClient.resumePausedMutations setDefaultOptions(options: DefaultOptions): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L914) +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1545,7 +1546,7 @@ QueryCoreClient.setDefaultOptions setMutationDefaults(mutationKey: readonly unknown[], options: OmitKeyof, "mutationKey">): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:996](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L996) +Defined in: [packages/query-core/src/queryClient.ts:999](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L999) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1615,7 +1616,7 @@ setQueriesData = QueryFilt ): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L338) +Defined in: [packages/query-core/src/queryClient.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L341) Synchronous way to immediately update the cached data of multiple queries at once, using filters or partial query key matching. Only queries that already exist and match the given @@ -1688,7 +1689,7 @@ setQueryData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L285) +Defined in: [packages/query-core/src/queryClient.ts:288](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L288) Synchronous way to immediately update a query's cached data. If the updater (or the value passed) resolves to `undefined`, the cache is left untouched and no query is created; @@ -1765,7 +1766,7 @@ QueryCoreClient.setQueryData setQueryDefaults(queryKey: readonly unknown[], options: Partial, "queryKey">>): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L934) +Defined in: [packages/query-core/src/queryClient.ts:937](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L937) Sets default options for queries whose query key partially matches the given `queryKey`. diff --git a/docs/framework/solid/reference/functions/useIsFetching.md b/docs/framework/solid/reference/functions/useIsFetching.md index 4c68d36cda9..039c70691e8 100644 --- a/docs/framework/solid/reference/functions/useIsFetching.md +++ b/docs/framework/solid/reference/functions/useIsFetching.md @@ -11,10 +11,10 @@ redirect_from: function useIsFetching(filters?: Accessor>, queryClient?: Accessor): Accessor; ``` -Defined in: [packages/solid-query/src/useIsFetching.ts:27](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useIsFetching.ts#L27) +Defined in: [packages/solid-query/src/useIsFetching.ts:28](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useIsFetching.ts#L28) The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching -in the background (useful for app-wide loading indicators). +in the background by default (useful for app-wide loading indicators). ## Parameters @@ -23,6 +23,8 @@ in the background (useful for app-wide loading indicators). `Accessor`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> An accessor returning the [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. +`fetchStatus` defaults to `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count +queries in that status instead. @@ -41,8 +43,7 @@ will be used. `Accessor`\<`number`\> -An accessor for the `number` of the queries that your application is currently loading or fetching -in the background. +An accessor for the `number` of matching queries with the requested `fetchStatus`. ## Example diff --git a/docs/framework/svelte/reference/classes/QueryClient.md b/docs/framework/svelte/reference/classes/QueryClient.md index 37864f12052..596cb65a878 100644 --- a/docs/framework/svelte/reference/classes/QueryClient.md +++ b/docs/framework/svelte/reference/classes/QueryClient.md @@ -53,7 +53,7 @@ Defined in: [packages/query-core/src/queryClient.ts:88](https://github.com/TanSt cancelQueries(filters?: QueryFilters, cancelOptions?: CancelOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:461](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L461) +Defined in: [packages/query-core/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L464) Cancels outgoing fetches for queries matching the given filters. Most useful when performing optimistic updates, since any outgoing refetch that resolves afterwards would otherwise @@ -104,7 +104,7 @@ await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) clear(): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:1168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1168) +Defined in: [packages/query-core/src/queryClient.ts:1171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1171) Clears both the query cache and the mutation cache this client is connected to. @@ -129,7 +129,7 @@ queryClient.clear() defaultMutationOptions>(options?: T): T; ``` -Defined in: [packages/query-core/src/queryClient.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1143) +Defined in: [packages/query-core/src/queryClient.ts:1146](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1146) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then @@ -166,7 +166,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1054) +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the caller into their final, defaulted form: merging the client's own `defaultOptions.queries`, @@ -223,7 +223,7 @@ The defaulted options, with `queryHash` and dependent defaults (e.g. ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:809](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L809) +Defined in: [packages/query-core/src/queryClient.ts:812](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L812) Returns the cached data of an infinite query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -278,7 +278,7 @@ Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This ensureQueryData(options: EnsureQueryDataOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L207) +Defined in: [packages/query-core/src/queryClient.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L210) Returns the cached data of a query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -329,7 +329,7 @@ Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method fetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:753](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L753) +Defined in: [packages/query-core/src/queryClient.ts:756](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L756) Fetches and caches an infinite query, or returns its cached data if it isn't stale. @@ -383,7 +383,7 @@ Use queryClient.infiniteQuery(options) instead. This method will be removed in t fetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:647](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L647) +Defined in: [packages/query-core/src/queryClient.ts:650](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L650) Fetches and caches a query, or returns its cached data if it isn't stale. Unlike in observers, the fetch isn't retried unless `retry` is set. @@ -438,7 +438,7 @@ Use queryClient.query(options) instead. This method will be removed in the next getDefaultOptions(): DefaultOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:893](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L893) +Defined in: [packages/query-core/src/queryClient.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L896) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -466,7 +466,7 @@ const defaultOptions = queryClient.getDefaultOptions() getMutationCache(): MutationCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:877](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L877) +Defined in: [packages/query-core/src/queryClient.ts:880](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L880) Returns the mutation cache this client is connected to. @@ -494,7 +494,7 @@ const mutations = mutationCache.findAll({ status: 'pending' }) getMutationDefaults(mutationKey: readonly unknown[]): OmitKeyof, "mutationKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:1026](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1026) +Defined in: [packages/query-core/src/queryClient.ts:1029](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1029) Returns the default options registered for mutations whose mutation key partially matches the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered @@ -529,7 +529,7 @@ const defaultOptions = queryClient.getMutationDefaults(['addPost']) getQueriesData = QueryFilters>(filters: TQueryFilters): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:253](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L253) +Defined in: [packages/query-core/src/queryClient.ts:256](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L256) Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. Only queries matching the given filters are returned; if none match, an empty array is @@ -583,7 +583,7 @@ const data = queryClient.getQueriesData({ queryKey: ['posts'] }) getQueryCache(): QueryCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:861](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L861) +Defined in: [packages/query-core/src/queryClient.ts:864](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L864) Returns the query cache this client is connected to. @@ -611,7 +611,7 @@ const queries = queryCache.findAll({ queryKey: ['posts'] }) getQueryData>(queryKey: TTaggedQueryKey): TInferredQueryFnData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L187) +Defined in: [packages/query-core/src/queryClient.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L190) Imperative (non-reactive) way to retrieve data for a QueryKey. Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. @@ -659,7 +659,7 @@ The cached data for the query, or `undefined` if no query with this key has been getQueryDefaults(queryKey: readonly unknown[]): OmitKeyof, "queryKey">; ``` -Defined in: [packages/query-core/src/queryClient.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L966) +Defined in: [packages/query-core/src/queryClient.ts:969](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L969) Returns the default options registered for queries whose query key partially matches the given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults @@ -696,7 +696,7 @@ getQueryState, TQueryKey extends readonly unknown[] = readonly unknown[], TPageParam = unknown>(options: InfiniteQueryExecuteOptions): Promise[] ? InfiniteData : TData>; ``` -Defined in: [packages/query-core/src/queryClient.ts:722](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L722) +Defined in: [packages/query-core/src/queryClient.ts:725](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L725) Asynchronous method to fetch and cache an infinite query, resolving with an [InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. @@ -822,7 +822,7 @@ try { invalidateQueries(filters?: InvalidateQueryFilters, options?: InvalidateOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:494](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L494) +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) Marks queries matching the given filters as invalidated. Unlike [QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. @@ -874,11 +874,11 @@ await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' isFetching = QueryFilters>(filters?: TQueryFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:151](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L151) +Defined in: [packages/query-core/src/queryClient.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L152) -Returns the number of queries in the cache that are currently fetching, optionally -matching a set of filters. This includes background-fetching, loading new pages, and -loading more infinite query results. +Returns the number of queries in the cache matching a set of filters. By default, counts +fetching queries, including background-fetching, loading new pages, and loading more +infinite query results. #### Type Parameters @@ -892,14 +892,15 @@ loading more infinite query results. `TQueryFilters` -Narrows down which fetching queries are counted. Without filters, every -fetching query is counted. +Narrows down which queries are counted. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries +in that status instead. #### Returns `number` -The number of matching queries whose `fetchStatus` is `'fetching'`. +The number of matching queries with the requested `fetchStatus`. #### Example @@ -917,7 +918,7 @@ if (queryClient.isFetching()) { isMutating = MutationFilters>(filters?: TMutationFilters): number; ``` -Defined in: [packages/query-core/src/queryClient.ts:171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L171) +Defined in: [packages/query-core/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L174) Returns the number of mutations in the cache that are currently pending, optionally matching a set of filters. @@ -978,7 +979,7 @@ the shared listeners until the last one unmounts. prefetchInfiniteQuery(options: FetchInfiniteQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:781](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L781) +Defined in: [packages/query-core/src/queryClient.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L784) Fetches and caches an infinite query like [QueryClient#fetchInfiniteQuery](#fetchinfinitequery), but ignores the result and any error. @@ -1032,7 +1033,7 @@ Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.ca prefetchQuery(options: FetchQueryOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:686](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L686) +Defined in: [packages/query-core/src/queryClient.ts:689](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L689) Fetches and caches a query like [QueryClient#fetchQuery](#fetchquery), but ignores the result and any error. @@ -1082,7 +1083,7 @@ Use queryClient.query(options) instead. You can swallow errors with `.catch(noop query(options: QueryExecuteOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L595) +Defined in: [packages/query-core/src/queryClient.ts:598](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L598) Asynchronous method to fetch and cache a query, resolving with the data or throwing with the error. @@ -1165,7 +1166,7 @@ try { refetchQueries(filters?: RefetchQueryFilters, options?: RefetchOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:535](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L535) +Defined in: [packages/query-core/src/queryClient.ts:538](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L538) Refetches queries matching the given filters, regardless of whether they are stale. Without filters, every query in the cache is refetched. Queries that are disabled, or static (only @@ -1218,7 +1219,7 @@ await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) removeQueries(filters?: QueryFilters): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) +Defined in: [packages/query-core/src/queryClient.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L400) Removes queries from the cache that match the given filters. Unlike [QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes @@ -1258,7 +1259,7 @@ queryClient.removeQueries({ queryKey: ['posts'], exact: true }) resetQueries(filters?: QueryFilters, options?: ResetOptions): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:422](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L422) +Defined in: [packages/query-core/src/queryClient.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L425) Resets queries matching the given filters back to their initial state (e.g. any `initialData`), notifying subscribers rather than removing them. Active queries among the @@ -1306,7 +1307,7 @@ await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) resumePausedMutations(): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:842](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L842) +Defined in: [packages/query-core/src/queryClient.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L845) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. @@ -1334,7 +1335,7 @@ await queryClient.resumePausedMutations() setDefaultOptions(options: DefaultOptions): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L914) +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) Dynamically sets the default options for this client, overwriting any previously defined default options. @@ -1376,7 +1377,7 @@ queryClient.setDefaultOptions({ setMutationDefaults(mutationKey: readonly unknown[], options: OmitKeyof, "mutationKey">): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:996](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L996) +Defined in: [packages/query-core/src/queryClient.ts:999](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L999) Sets default options for mutations whose mutation key partially matches the given `mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration @@ -1440,7 +1441,7 @@ setQueriesData = QueryFilt ): [readonly unknown[], TQueryFnData | undefined][]; ``` -Defined in: [packages/query-core/src/queryClient.ts:338](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L338) +Defined in: [packages/query-core/src/queryClient.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L341) Synchronous way to immediately update the cached data of multiple queries at once, using filters or partial query key matching. Only queries that already exist and match the given @@ -1507,7 +1508,7 @@ setQueryData | undefined; ``` -Defined in: [packages/query-core/src/queryClient.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L285) +Defined in: [packages/query-core/src/queryClient.ts:288](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L288) Synchronous way to immediately update a query's cached data. If the updater (or the value passed) resolves to `undefined`, the cache is left untouched and no query is created; @@ -1578,7 +1579,7 @@ queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) setQueryDefaults(queryKey: readonly unknown[], options: Partial, "queryKey">>): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L934) +Defined in: [packages/query-core/src/queryClient.ts:937](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L937) Sets default options for queries whose query key partially matches the given `queryKey`. diff --git a/docs/framework/svelte/reference/functions/useIsFetching.md b/docs/framework/svelte/reference/functions/useIsFetching.md index e6306218387..f26f1fb626d 100644 --- a/docs/framework/svelte/reference/functions/useIsFetching.md +++ b/docs/framework/svelte/reference/functions/useIsFetching.md @@ -12,7 +12,7 @@ function useIsFetching(filters?: QueryFilters, queryClient?: Defined in: [packages/svelte-query/src/useIsFetching.svelte.ts:40](https://github.com/TanStack/query/blob/main/packages/svelte-query/src/useIsFetching.svelte.ts#L40) The `useIsFetching` function returns the `number` of the queries that your application is loading or -fetching in the background (useful for app-wide loading indicators). +fetching in the background by default (useful for app-wide loading indicators). ## Parameters @@ -20,8 +20,8 @@ fetching in the background (useful for app-wide loading indicators). [`QueryFilters`](../interfaces/QueryFilters.md)\ -[QueryFilters](../interfaces/QueryFilters.md) to narrow down which queries to count. Omit to count every fetching -query. +[QueryFilters](../interfaces/QueryFilters.md) to narrow down which queries to count. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. @@ -47,7 +47,7 @@ be used. `ReactiveValue`\<`number`\> -A reactive value — read `.current` to get how many matching queries are currently fetching. +A reactive value — read `.current` to get how many queries match the requested `fetchStatus` and other filters. ## Examples diff --git a/docs/framework/vue/reference/classes/QueryClient.md b/docs/framework/vue/reference/classes/QueryClient.md index f95ccfd17c2..c7a75c3ca57 100644 --- a/docs/framework/vue/reference/classes/QueryClient.md +++ b/docs/framework/vue/reference/classes/QueryClient.md @@ -125,7 +125,7 @@ QC.cancelQueries clear(): void; ``` -Defined in: [packages/query-core/src/queryClient.ts:1168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1168) +Defined in: [packages/query-core/src/queryClient.ts:1171](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1171) Clears both the query cache and the mutation cache this client is connected to. @@ -156,7 +156,7 @@ QC.clear defaultMutationOptions>(options?: T): T; ``` -Defined in: [packages/query-core/src/queryClient.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1143) +Defined in: [packages/query-core/src/queryClient.ts:1146](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1146) The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework adapters (e.g. inside `useMutation`) to merge the client's `defaultOptions.mutations`, then @@ -199,7 +199,7 @@ defaultQueryOptions): DefaultedQueryObserverOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1054) +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the caller into their final, defaulted form: merging the client's own `defaultOptions.queries`, @@ -262,7 +262,7 @@ QC.defaultQueryOptions ensureInfiniteQueryData(options: EnsureInfiniteQueryDataOptions): Promise>; ``` -Defined in: [packages/query-core/src/queryClient.ts:809](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L809) +Defined in: [packages/query-core/src/queryClient.ts:812](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L812) Returns the cached data of an infinite query, or fetches it if there is none. With `revalidateIfStale`, stale cached data is also refetched in the background. @@ -682,7 +682,7 @@ QC.fetchQuery getDefaultOptions(): DefaultOptions; ``` -Defined in: [packages/query-core/src/queryClient.ts:893](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L893) +Defined in: [packages/query-core/src/queryClient.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L896) Returns the default options that were set when creating the client, or via [QueryClient#setDefaultOptions](#setdefaultoptions). @@ -716,7 +716,7 @@ QC.getDefaultOptions getMutationCache(): MutationCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:877](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L877) +Defined in: [packages/query-core/src/queryClient.ts:880](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L880) Returns the mutation cache this client is connected to. @@ -847,7 +847,7 @@ QC.getQueriesData getQueryCache(): QueryCache; ``` -Defined in: [packages/query-core/src/queryClient.ts:861](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L861) +Defined in: [packages/query-core/src/queryClient.ts:864](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L864) Returns the query cache this client is connected to. @@ -1272,9 +1272,9 @@ isFetching(filters?: MaybeRefDeep>): number; Defined in: [packages/vue-query/src/queryClient.ts:67](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L67) -Returns the number of queries in the cache that are currently fetching, optionally -matching a set of filters. This includes background-fetching, loading new pages, and -loading more infinite query results. +Returns the number of queries in the cache matching a set of filters. By default, counts +fetching queries, including background-fetching, loading new pages, and loading more +infinite query results. #### Parameters @@ -1282,14 +1282,15 @@ loading more infinite query results. `MaybeRefDeep`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` -Narrows down which fetching queries are counted. Without filters, every -fetching query is counted. +Narrows down which queries are counted. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries +in that status instead. #### Returns `number` -The number of matching queries whose `fetchStatus` is `'fetching'`. +The number of matching queries with the requested `fetchStatus`. #### Example @@ -1939,7 +1940,7 @@ QC.resetQueries resumePausedMutations(): Promise; ``` -Defined in: [packages/query-core/src/queryClient.ts:842](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L842) +Defined in: [packages/query-core/src/queryClient.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L845) Resumes mutations that were paused because there was no network connection. Does nothing (resolving immediately) if the client is currently offline. diff --git a/docs/framework/vue/reference/functions/useIsFetching.md b/docs/framework/vue/reference/functions/useIsFetching.md index e7684e96f3f..78a282360f6 100644 --- a/docs/framework/vue/reference/functions/useIsFetching.md +++ b/docs/framework/vue/reference/functions/useIsFetching.md @@ -14,7 +14,7 @@ function useIsFetching(fetchingFilters?: UseIsFetchingFilters, queryClient?: Que Defined in: [packages/vue-query/src/useIsFetching.ts:55](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L55) The `useIsFetching` composable returns a `ref` to the `number` of the queries that your application is -loading or fetching in the background (useful for app-wide loading indicators). +loading or fetching in the background by default (useful for app-wide loading indicators). `fetchingFilters` may be a plain object, `MaybeRefDeep`, or a reactive getter (`() => ({ ... })`) — pass a getter if the filters themselves depend on other reactive state. @@ -25,7 +25,8 @@ getter if the filters themselves depend on other reactive state. [`UseIsFetchingFilters`](../type-aliases/UseIsFetchingFilters.md) = `{}` -The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. +The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. `fetchStatus` defaults to +`'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. ### queryClient? @@ -38,8 +39,7 @@ will be used. `Ref`\<`number`\> -A `ref` to the `number` of the queries that your application is currently loading or fetching in -the background. +A `ref` to the `number` of matching queries with the requested `fetchStatus`. ## Examples diff --git a/packages/angular-query-experimental/src/inject-is-fetching.ts b/packages/angular-query-experimental/src/inject-is-fetching.ts index 54b6f289e3d..624a122d929 100644 --- a/packages/angular-query-experimental/src/inject-is-fetching.ts +++ b/packages/angular-query-experimental/src/inject-is-fetching.ts @@ -24,11 +24,11 @@ export interface InjectIsFetchingOptions { /** * Injects a signal that tracks the number of queries that your application is loading or fetching in the - * background (useful for app-wide loading indicators). - * @param filters - The {@link QueryFilters} to narrow down the matched queries. + * background by default (useful for app-wide loading indicators). + * @param filters - The {@link QueryFilters} to narrow down the matched queries. `fetchStatus` defaults to + * `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. * @param options - Additional configuration - * @returns A `Signal` with the number of queries that your application is currently loading or fetching in - * the background. + * @returns A `Signal` with the number of matching queries with the requested `fetchStatus`. * @example * ```angular-ts * @Component({ diff --git a/packages/lit-query/src/useIsFetching.ts b/packages/lit-query/src/useIsFetching.ts index 4bd30cbaf35..70b90ccd9fb 100644 --- a/packages/lit-query/src/useIsFetching.ts +++ b/packages/lit-query/src/useIsFetching.ts @@ -8,7 +8,7 @@ import type { ReactiveControllerHost } from 'lit' * Accessor returned by `useIsFetching`. * * Call the accessor or read its `current` property to get the number of - * currently fetching queries that match the filters. + * queries that match the filters, defaulting to currently fetching queries. */ export type IsFetchingAccessor = ValueAccessor & { destroy: () => void } @@ -111,17 +111,18 @@ class IsFetchingController extends BaseController { /** * Creates a Lit reactive controller that tracks how many matching queries are - * currently fetching. + * currently fetching by default. * * When `filters` is a function, it is re-read during host updates so the count * can follow reactive host state. If `queryClient` is omitted, the controller * resolves the client from the nearest connected `QueryClientProvider`. * @param host - The Lit reactive controller host that owns the cache * subscription. - * @param filters - Query filters, or a getter that returns query filters. + * @param filters - Query filters, or a getter that returns query filters. `fetchStatus` defaults to + * `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. * @param queryClient - Optional explicit query client. Provide this for * controllers that should not resolve a client from Lit context. - * @returns An accessor for the current number of matching fetching queries. + * @returns An accessor for the number of matching queries with the requested `fetchStatus`. * @example * ```ts * import { LitElement, html } from 'lit' diff --git a/packages/preact-query/src/useIsFetching.ts b/packages/preact-query/src/useIsFetching.ts index 3cbf2e6a856..7e4be4c6656 100644 --- a/packages/preact-query/src/useIsFetching.ts +++ b/packages/preact-query/src/useIsFetching.ts @@ -7,12 +7,12 @@ import type { QueryClient, QueryFilters } from '@tanstack/query-core' /** * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching in - * the background (useful for app-wide loading indicators). - * @param filters - The {@link QueryFilters} to narrow down the matched queries. + * the background by default (useful for app-wide loading indicators). + * @param filters - The {@link QueryFilters} to narrow down the matched queries. `fetchStatus` defaults to + * `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns Will be the `number` of the queries that your application is currently loading or fetching in the - * background. + * @returns The `number` of matching queries with the requested `fetchStatus`. * @example * ```tsx * import { useIsFetching } from '@tanstack/preact-query' diff --git a/packages/query-core/src/__tests__/queryClient.test.tsx b/packages/query-core/src/__tests__/queryClient.test.tsx index 8cc60a62d23..bfadda6fbb5 100644 --- a/packages/query-core/src/__tests__/queryClient.test.tsx +++ b/packages/query-core/src/__tests__/queryClient.test.tsx @@ -409,6 +409,66 @@ describe('queryClient', () => { }) describe('isFetching', () => { + it.each([ + { fetchStatus: 'fetching', otherFetchStatus: 'idle' }, + { fetchStatus: 'paused', otherFetchStatus: 'fetching' }, + { fetchStatus: 'idle', otherFetchStatus: 'fetching' }, + ] as const)( + 'should count $fetchStatus queries and apply other filters', + ({ fetchStatus, otherFetchStatus }) => { + const key = queryKey() + const query = queryCache.build(queryClient, { queryKey: key }) + const child = queryCache.build(queryClient, { + queryKey: [...key, 'child'], + }) + const unrelated = queryCache.build(queryClient, { + queryKey: queryKey(), + }) + const other = queryCache.build(queryClient, { + queryKey: [...key, 'other'], + }) + query.setState({ fetchStatus }) + child.setState({ fetchStatus }) + unrelated.setState({ fetchStatus }) + other.setState({ fetchStatus: otherFetchStatus }) + + expect(queryClient.isFetching({ fetchStatus })).toBe(3) + expect(queryClient.isFetching({ queryKey: key, fetchStatus })).toBe(2) + expect( + queryClient.isFetching({ queryKey: key, exact: true, fetchStatus }), + ).toBe(1) + expect( + queryClient.isFetching({ + queryKey: key, + fetchStatus, + predicate: (candidate) => candidate.queryHash === child.queryHash, + }), + ).toBe(1) + expect( + queryClient.isFetching({ queryKey: queryKey(), fetchStatus }), + ).toBe(0) + }, + ) + + it('should default to fetching when fetchStatus is omitted or undefined', () => { + const key = queryKey() + for (const fetchStatus of ['fetching', 'paused', 'idle'] as const) { + queryCache + .build(queryClient, { queryKey: [...key, fetchStatus] }) + .setState({ fetchStatus }) + } + queryCache + .build(queryClient, { queryKey: queryKey() }) + .setState({ fetchStatus: 'fetching' }) + + expect(queryClient.isFetching()).toBe(2) + expect(queryClient.isFetching({})).toBe(2) + expect(queryClient.isFetching({ queryKey: key })).toBe(1) + expect( + queryClient.isFetching({ queryKey: key, fetchStatus: undefined }), + ).toBe(1) + }) + it('should return length of fetching queries', async () => { expect(queryClient.isFetching()).toBe(0) diff --git a/packages/query-core/src/queryClient.ts b/packages/query-core/src/queryClient.ts index 3d8e3e6f690..7a97a0920af 100644 --- a/packages/query-core/src/queryClient.ts +++ b/packages/query-core/src/queryClient.ts @@ -135,12 +135,13 @@ export class QueryClient { } /** - * Returns the number of queries in the cache that are currently fetching, optionally - * matching a set of filters. This includes background-fetching, loading new pages, and - * loading more infinite query results. - * @param filters - Narrows down which fetching queries are counted. Without filters, every - * fetching query is counted. - * @returns The number of matching queries whose `fetchStatus` is `'fetching'`. + * Returns the number of queries in the cache matching a set of filters. By default, counts + * fetching queries, including background-fetching, loading new pages, and loading more + * infinite query results. + * @param filters - Narrows down which queries are counted. `fetchStatus` defaults to + * `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries + * in that status instead. + * @returns The number of matching queries with the requested `fetchStatus`. * @example * ```ts * if (queryClient.isFetching()) { @@ -151,8 +152,10 @@ export class QueryClient { isFetching = QueryFilters>( filters?: TQueryFilters, ): number { - return this.#queryCache.findAll({ ...filters, fetchStatus: 'fetching' }) - .length + return this.#queryCache.findAll({ + ...filters, + fetchStatus: filters?.fetchStatus ?? 'fetching', + }).length } /** diff --git a/packages/react-query/src/__tests__/useIsFetching.test.tsx b/packages/react-query/src/__tests__/useIsFetching.test.tsx index 3ea44967495..e247c43ed36 100644 --- a/packages/react-query/src/__tests__/useIsFetching.test.tsx +++ b/packages/react-query/src/__tests__/useIsFetching.test.tsx @@ -15,6 +15,45 @@ describe('useIsFetching', () => { vi.useRealTimers() }) + it('should track fetchStatus filters as queries change status', async () => { + const queryClient = new QueryClient() + const key = queryKey() + const query = queryClient.getQueryCache().build(queryClient, { + queryKey: key, + }) + query.setState({ fetchStatus: 'paused' }) + + function Page() { + const fetching = useIsFetching({ queryKey: key }) + const paused = useIsFetching({ queryKey: key, fetchStatus: 'paused' }) + const idle = useIsFetching({ queryKey: key, fetchStatus: 'idle' }) + + return ( +
+ fetching: {fetching}, paused: {paused}, idle: {idle} +
+ ) + } + + const rendered = renderWithClient(queryClient, ) + + expect( + rendered.getByText('fetching: 0, paused: 1, idle: 0'), + ).toBeInTheDocument() + + query.setState({ fetchStatus: 'fetching' }) + await vi.advanceTimersByTimeAsync(0) + expect( + rendered.getByText('fetching: 1, paused: 0, idle: 0'), + ).toBeInTheDocument() + + query.setState({ fetchStatus: 'idle' }) + await vi.advanceTimersByTimeAsync(0) + expect( + rendered.getByText('fetching: 0, paused: 0, idle: 1'), + ).toBeInTheDocument() + }) + // See https://github.com/tannerlinsley/react-query/issues/105 it('should update as queries start and stop fetching', async () => { const queryClient = new QueryClient() diff --git a/packages/react-query/src/useIsFetching.ts b/packages/react-query/src/useIsFetching.ts index 6fd5dd72ea9..443111f5235 100644 --- a/packages/react-query/src/useIsFetching.ts +++ b/packages/react-query/src/useIsFetching.ts @@ -7,12 +7,12 @@ import type { QueryClient, QueryFilters } from '@tanstack/query-core' /** * The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching in - * the background (useful for app-wide loading indicators). - * @param filters - The {@link QueryFilters} to narrow down the matched queries. + * the background by default (useful for app-wide loading indicators). + * @param filters - The {@link QueryFilters} to narrow down the matched queries. `fetchStatus` defaults to + * `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns Will be the `number` of the queries that your application is currently loading or fetching in the - * background. + * @returns The `number` of matching queries with the requested `fetchStatus`. * @example * ```tsx * import { useIsFetching } from '@tanstack/react-query' diff --git a/packages/solid-query/src/useIsFetching.ts b/packages/solid-query/src/useIsFetching.ts index 1b39b1ccdcc..24b00b6424e 100644 --- a/packages/solid-query/src/useIsFetching.ts +++ b/packages/solid-query/src/useIsFetching.ts @@ -6,12 +6,13 @@ import type { Accessor } from 'solid-js' /** * The `useIsFetching` primitive returns the `number` of the queries that your application is loading or fetching - * in the background (useful for app-wide loading indicators). + * in the background by default (useful for app-wide loading indicators). * @param filters - An accessor returning the {@link QueryFilters} to narrow down the matched queries. + * `fetchStatus` defaults to `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count + * queries in that status instead. * @param queryClient - An accessor for a custom `QueryClient`. Otherwise, the one from the nearest context * will be used. - * @returns An accessor for the `number` of the queries that your application is currently loading or fetching - * in the background. + * @returns An accessor for the `number` of matching queries with the requested `fetchStatus`. * @example * ```tsx * import { useIsFetching } from '@tanstack/solid-query' diff --git a/packages/svelte-query/src/useIsFetching.svelte.ts b/packages/svelte-query/src/useIsFetching.svelte.ts index 05be0083c04..f5dc45c1949 100644 --- a/packages/svelte-query/src/useIsFetching.svelte.ts +++ b/packages/svelte-query/src/useIsFetching.svelte.ts @@ -4,12 +4,12 @@ import type { QueryClient, QueryFilters } from '@tanstack/query-core' /** * The `useIsFetching` function returns the `number` of the queries that your application is loading or - * fetching in the background (useful for app-wide loading indicators). - * @param filters - {@link QueryFilters} to narrow down which queries to count. Omit to count every fetching - * query. + * fetching in the background by default (useful for app-wide loading indicators). + * @param filters - {@link QueryFilters} to narrow down which queries to count. `fetchStatus` defaults to + * `'fetching'` when omitted or `undefined`; set it to `'paused'` or `'idle'` to count queries in that status instead. * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will * be used. - * @returns A reactive value — read `.current` to get how many matching queries are currently fetching. + * @returns A reactive value — read `.current` to get how many queries match the requested `fetchStatus` and other filters. * @example * ```svelte *