Filter Properties
TheQueryFilters interface supports the following properties:
Query Key Filtering
Filter by query key with partial or exact matching:By default, query key filtering uses partial matching. A query matches if the filter key is a prefix of the query’s key.
Exact Matching
Useexact: true to match only queries with the exact key:
Type Filtering
Filter by query activity status:1
Active queries
Queries with one or more active observers (mounted components)
2
Inactive queries
Queries in the cache with no active observers
3
All queries
Both active and inactive queries
Stale Filtering
Filter by staleness:Fetch Status Filtering
Filter by fetch status:Predicate Filtering
Use custom logic to filter queries:Combining Filters
Combine multiple filter properties:Using Filters with invalidateQueries
Invalidate specific queries:Using Filters with refetchQueries
Refetch matching queries:Using Filters with removeQueries
Remove queries from the cache:Finding Queries
Find queries in the cache using filters:isFetching with Filters
Count currently fetching queries:Mutation Filters
Similar filtering for mutations:Real-World Examples
Selective Cache Invalidation
Periodic Cache Cleanup
Smart Refresh
Best Practices
See Also
- Query Invalidation - Deep dive into invalidation patterns
- Query Keys - Structuring effective query keys
- Mutations - Updating data and invalidating queries