Skip to content
English

TanStack Query

The TanStack Query panel lists the queries and mutations in your app’s QueryClient and keeps them up to date as your app fetches. You can edit a query’s cached data, and refetch, invalidate or remove queries from the desktop app.

Using TanStack Query in the desktop app

Accepts false | QueryClientLike Opt-in

Pass your QueryClient itself as tanstackQuery, not an object wrapping it:

index.ts
import { QueryClient } from '@tanstack/query-core';
import { init } from '@xerlock/client';
const queryClient = new QueryClient();
init({ tanstackQuery: queryClient });

The SDK doesn’t depend on TanStack Query. Any object with this shape works:

QueryClientLike
MemberDescription
getQueryCache(): QueryCacheLikeThe cache of queries. The SDK reads and subscribes to it to report queries.
getMutationCache(): MutationCacheLikeThe cache of mutations. The SDK reads and subscribes to it to report mutations.
setQueryData(queryKey: readonly unknown[], data: unknown): unknownOverwrites the cached data for a query. Used by the desktop app's edit action.
refetchQueries(filters?: QueryFilterLike): Promise<void>Refetches queries matching filters, or every query when omitted.
invalidateQueries(filters?: QueryFilterLike): Promise<void>Marks queries matching filters as stale and refetches active ones, or every query when omitted.

Leave out tanstackQuery, or pass false, to hide the TanStack Query panel for this app.

  • The TanStack Query panel is missing: pass your QueryClient as tanstackQuery in init().