Skip to main content
Version: 2.x

invalidateQueries(...)

The method programmatically invalidates cached data within the QueryClient. Refer to the TanStack Query Invalidation 🌴 guide for more information.

Invalidates queries for the specified endpoint using the provided filters.

qraft.<service>.<operation>.invalidateQueries(
filters
)

Arguments

  1. filters: QueryFiltersByParameters | QueryFiltersByQueryKey
    • Required, represents the Query Filters 🌴 to be used, strictly-typed ✨
    • filters.parameters: { path, query, header } will be used for filtering queries by parameters
    • filters.infinite: boolean will be used to filter infinite or normal queries
    • filters.queryKey: QueryKey will be used for filtering queries by QueryKey instead of parameters
      • filters.queryKey and filters.parameters are mutually exclusive
    • filters.predicate?: (query: Query) => boolean will be used for filtering queries by custom predicate
    • If not provided
      • All queries for the specified endpoint will be invalidated

Returns

Promise<void>: A promise that resolves once the invalidation is complete.

Examples

Queries invalidation with the specified parameters:

/**
* Will invalidate queries with the specified parameters:
* ###
* GET /entities/3e3e-3e3e-3e3e
* x-monite-version: 2023-09-01
**/
qraft.entities.getEntities.invalidateQueries(
{
infinite: false,
parameters: {
header: {
'x-monite-version': '2023-09-01',
},
path: {
entity_id: '3e3e-3e3e-3e3e',
},
},
}
);