Todos with Query
Add or toggle a todo. Watch status flip to refetching — that is invalidateQueries pulling a fresh list.
queryKey: ["example-todos","all"]
status: loading
fetches: 0
Loading list…
queryKey: ['todos', filter]
queryFn: () => todosApi.list(filter)
// after mutate:
queryClient.invalidateQueries({ queryKey: ['todos'] })Query owns the cached list. After a mutation, invalidate so the UI refetches — do not mirror the Nest array in Redux.