When a server mutation (e.g., model discovery refresh) changes data that feeds multiple cached selectors/queries, use RTK Query tag invalidation to refresh all dependent caches—especially indirect ones.
Guideline
Example (pattern)
const refreshProviderModels = builder.mutation<ModelProviderKey[], string>({
query: (provider) => ({
url: `/providers/${encodeURIComponent(provider)}/refresh-models`,
method: 'POST',
}),
invalidatesTags: [
'Models',
'DBKeys',
{ type: 'Providers' as const, id: provider },
],
});
Application checklist
models) and which UI components depend on it.invalidatesTags for those dependencies.updateQueryData/patching unless the response can be mapped losslessly to the cached query’s existing item shape.