query icon indicating copy to clipboard operation
query copied to clipboard

Svelte createQuery doesn't support passing in a persister properly

Open sgcullen opened this issue 2 months ago • 0 comments

Describe the bug

It is possible to add a persister (I'm using the experimental_createQueryPersister) to the QueryClient via defaultOptions as follows:

export const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: 60000
      persister: persister.persisterFn,
    },
  },
});

Previously it also used to be possible to set the persister when using createQuery for example:

const query = createQuery(() => ({
    queryKey: ['todos'],
    queryFn: () => fetchTodos(),
    persister: persister.persisterFn
  }))

This would then override the default persister defined in the QueryClient, however, this now throws type errors.

Is this a known issue or am I doing something wrong?

Sometimes it's quite useful to be able to override the default persister, for example, if I want to pass in a "buster" to forcibly invalidate the cache.

Thanks!

Your minimal, reproducible example

na

Steps to reproduce

na

Expected behavior

na

How often does this bug happen?

None

Screenshots or Videos

na

Platform

na

Tanstack Query adapter

None

TanStack Query version

"@tanstack/query-core": "^5.90.2", "@tanstack/query-persist-client-core": "^5.90.2", "@tanstack/svelte-query": "^6.0.0",

TypeScript version

No response

Additional context

No response

sgcullen avatar Oct 04 '25 12:10 sgcullen