snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
26
packages/vue-query/src/queryCache.ts
Normal file
26
packages/vue-query/src/queryCache.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { QueryCache as QC } from '@tanstack/query-core'
|
||||
import { cloneDeepUnref } from './utils'
|
||||
import type {
|
||||
DefaultError,
|
||||
Query,
|
||||
QueryFilters,
|
||||
WithRequired,
|
||||
} from '@tanstack/query-core'
|
||||
import type { MaybeRefDeep } from './types'
|
||||
|
||||
/**
|
||||
* Vue-aware subclass of `@tanstack/query-core`'s `QueryCache`. `find`/`findAll` also accept a
|
||||
* {@link MaybeRefDeep} filters object, so `ref`s can be passed directly without unwrapping. Access it via
|
||||
* `queryClient.getQueryCache()` — `QueryClient` constructs one of these by default.
|
||||
*/
|
||||
export class QueryCache extends QC {
|
||||
find<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData>(
|
||||
filters: MaybeRefDeep<WithRequired<QueryFilters, 'queryKey'>>,
|
||||
): Query<TQueryFnData, TError, TData> | undefined {
|
||||
return super.find(cloneDeepUnref(filters))
|
||||
}
|
||||
|
||||
findAll(filters: MaybeRefDeep<QueryFilters> = {}): Array<Query> {
|
||||
return super.findAll(cloneDeepUnref(filters))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user