TanStack / TanStack/query

Svelte createQuery doesn't support passing in a persister properly

Open
#9,729 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

package: svelte-query
Dominant language
TypeScript
Stars
50.3k
Forks
4.2k
Avg merge
18h 25m
Merged PRs (30d)
200

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by inspecting the Svelte createQuery option types and how they pass options to QueryClient, then compare per-query persister handling with defaultOptions. Done means a persister supplied to createQuery is accepted without type errors and overrides the client default, with regression coverage for that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.