TanStackT
TanStack3y ago
51 replies
slow-yellow

Use derived stores with svelte-query 5

In the svelte-query 5 docs, it says you can pass a writable store for queryOptions like so:
const queryOptions = writable({
  queryKey: ['refetch'],
  queryFn: async () => await fetch(endpoint).then((r) => r.json()),
  refetchInterval: 1000,
})
const query = createQuery(queryOptions)

I tested and it works great. However, I then tried passing a derived store, and get an error that it can't read the data from the derived store (it says my queryKey and queryFn are empty, even though if I subscribe to the derived store I can see they are populated).

Does svelte-query 5 not support derived stores for query options?
Was this page helpful?