# TanStack Query

> Browse, edit, refetch and invalidate your app's TanStack Query cache from the desktop app. It is off until you pass your QueryClient.

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](/docs/desktop/tanstack-query/)

## Setup

**Accepts** `false | QueryClientLike` Opt-in

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

*index.ts*

```ts
import { QueryClient } from '@tanstack/query-core';
import { init } from '@xerlock/client';

const queryClient = new QueryClient();

init({ tanstackQuery: queryClient });
```

### Shapes

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

| Member                                                               | Description                                                                                       |
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `getQueryCache(): QueryCacheLike`                                    | The cache of queries. The SDK reads and subscribes to it to report queries.                       |
| `getMutationCache(): MutationCacheLike`                              | The cache of mutations. The SDK reads and subscribes to it to report mutations.                   |
| `setQueryData(queryKey: readonly unknown[], data: unknown): unknown` | Overwrites 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. |

### Turning it off

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

## Limits and Troubleshooting

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