Table of Contents

Method InvalidateQueries

Namespace
Velvet
Assembly
Velvet.Docs.dll

InvalidateQueries(QueryKey?)

Marks every entry whose key queryKey matches stale, and fetches again each one a mounted query is reading — TanStack Query's invalidateQueries({ queryKey }), with the partial match of its filter that QueryKey describes. For such an entry, a request already in flight is cancelled and started over when the entry holds data, so a result fetched before the change that invalidated it does not land as current, and joined when the entry is still waiting on its first result. An entry nothing reads is not fetched: a query mounting over it later fetches it, and a request it still has in flight, one whose query function takes no token, is left to land.

public VelvetTask InvalidateQueries(QueryKey? queryKey = null)

Parameters

queryKey QueryKey

The filter; null matches every entry.

Returns

VelvetTask

A task that completes once the requests this started have settled, whatever they did, so a mutation callback can return it to wait for the refetch as v5's onSuccess does.

InvalidateQueries(QueryFilters?, RefetchOptions?)

InvalidateQueries(QueryKey?) over the entries filters selects, TanStack Query's invalidateQueries(filters, options). Only entries an enabled query reads are fetched again.

public VelvetTask InvalidateQueries(QueryFilters? filters, RefetchOptions? options = null)

Parameters

filters QueryFilters

The entries to mark stale; null selects every entry.

options RefetchOptions

Whether the requests it starts cancel those in flight, and whether the task faults with their failure.

Returns

VelvetTask