TanStack

T

TanStack

TanStack is a community of passionate software engineers striving for high-quality, open-source software for web devs

Join

react-query-questions

solid-query-questions

table-questions

virtual-questions

router-questions

react-charts-questions

ranger-questions

vue-query-questions

svelte-query-questions

bling-questions

form-questions

angular-query-questions

start-questions

db-questions

start-showcase

router-showcase

📣-announcements

conscious-sapphire
conscious-sapphire8/2/2023

Using derived stores in mutations

In svelte-query 5, it looks like using a derived store for CreateMutationOptions is supported based on the types and at runtime it works as expected. However, in TS land none of the generics seem to be working: https://codesandbox.io/p/sandbox/cocky-varahamihira-xdcnff?embed=1&file=%2Fsrc%2Flib%2Fmutations.ts%3A12%2C33 Is this a known issue or am I doing something wrong?...
No description
correct-apricot
correct-apricot7/30/2023

Create typed wrapper for createQuery function

I have own configuration of createQuery (createAppQuery) and then I want to use this function for creating query in .svelte component. However I would like it to be typed exactly as original createQuery. Now I have just meaningless CreateAppQueryOptions and suppose, this should be integrated somehow with types from tanstack lib? ``` //types from tanstack package export declare function createAppQuery<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey>(options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, queryClient?: QueryClient): CreateQueryResult<TData, TError>;...
correct-apricot
correct-apricot7/29/2023

Svelte with tanstack query

I have folder queries/streamQuery.ts in my app. Its content of this file: ``` export function getStreamsQuery(refetchIntervalS: number = 10) { return createQuery({ queryKey: ['streams'],...
stuck-chocolate
stuck-chocolate7/15/2023

createQueries, check when all the queries loaded

Is there a way to check if all queries loaded without looping them all and check isLoading , when using createQueries?
conscious-sapphire
conscious-sapphire7/3/2023

svelte-query 5: useQueryClient tries to load from context even with override client

In svelte-query 5, you can now call createQuery() and useQueryClient with your own query client, rather than the one in context, like: ```javascript createQuery(options, myClient) // or useQueryClient(myClient)...
correct-apricot
correct-apricot6/30/2023

Documentation is confusing

I am new to Tanstack and Svelte as well. The documentation is confusing because svelte section is almost empty. Does that mean that all docs in React section is identical to Svelte as well?
conscious-sapphire
conscious-sapphire6/23/2023

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: ```javascript const queryOptions = writable({ queryKey: ['refetch'], queryFn: async () => await fetch(endpoint).then((r) => r.json()),...
fascinating-indigo
fascinating-indigo6/23/2023

What is the right way to import queryClient with SSR?

Hey, I am kinda confused what is the right way to access the QueryClient object in Svelte? I found two options:...
wise-white
wise-white6/7/2023

`isRefetching` is always true

In SvelteKit I'm trying to set up a traditional paginated table and disable the pagination controls while loading a new page. I'm doing something like the following: ```typescript <script lang="ts"> export let data: PageData...
conscious-sapphire
conscious-sapphire5/30/2023

Use createQuery without Context API?

Hi, is there anyway to use createQuery without using the Context API for fetching the QueryClient to use? I am trying to use createQuery outside the context of a Svelte component to fetch some data. I want createQuery to return a Svelte store like it does today. I just want to pass my own QueryClient instead of relying on Context.
other-emerald
other-emerald5/28/2023

TypeScript type hinting fails

I have followed the example shown in https://tanstack.com/query/latest/docs/svelte/ssr to a T, but I cannot get the type hint for the Readable result. 2nd picture shows my expectation for $query...
No description
wise-white
wise-white5/2/2023

Advice for complex custom hooks

Hey! I’m looking for a good pattern for complex custom hooks. My team is using Orval (https://github.com/anymaniax/orval) to generate TanStack custom hooks for each of our API endpoints. From those generated hooks, I would like to derive results that require >1 of them. Here’s one example. I’d like to compose the results from two queries. ```jsx...
like-gold
like-gold4/25/2023

Mutation not triggering updates properly

I have just started switching an application to using svelte-query. So far most of the mutations seem to work properly, with one exception: updates. I retrieve a list of objects via createQuery. I use that store to feed a table ($objects.data). When I modify a single instance of these objects with a mutation and call invalidateQueries(<queryKey>) no re-rendering is triggered on my table. To simplify things, I modified the playground sample and kicked out a lot of things like xxx.isFetching which triggers a re-render and finally got to a state where editing a todo on the list will not trigger a re-render: https://codesandbox.io/p/sandbox/peaceful-chebyshev-g1k6rq?file=%2Fsrc%2Froutes%2FEditTodo.svelte&selection=%5B%7B%22endColumn%22%3A9%2C%22endLineNumber%22%3A85%2C%22startColumn%22%3A9%2C%22startLineNumber%22%3A85%7D%5D ...
like-gold
like-gold4/14/2023

Use with custom stores?

Hi I was just wondering about the general idea / concept here: is this meant to be used in conjunction with stores / custom stores that hold the data of an application? Or is the idea to use things like 'createQuery' etc. and make use of the store that is created that way? So that would much more be implicit store creation. Which would mean that there is no need to create another store?...
harsh-harlequin
harsh-harlequin1/17/2023

createInfiniteQuery runs fetch, when initialData is defined

Hello, I have a main page in SvelteKit that has the following structure: +page.svelte ```js import {createInfiniteQuery} from '@tanstack/svelte-query'; export let data; // this has the initial data...
No description
equal-aqua
equal-aqua1/15/2023

SSR + SvelteKit w/prefetching data should only fetch during the prefetch and not client-side

The expected behavior is that there isn't an initial fetch on the client.
From the provided SSR example (https://tanstack.com/query/latest/docs/svelte/examples/svelte/ssr), it seems that there are two fetches occurring (one for the prefetch and one on the client) when I observe the events in the network tab in the screenshot (i.e. after hitting the browser refresh button for the CodeSandbox). Am I misinterpreting the intended behavior/implementation of this feature?...
No description
absent-sapphire
absent-sapphire1/12/2023

Svelte-query - undefined queryclient

I want to integrate svelte-query in sveltekit app , as given in docs I have done all installation and setup but am getting this weird error in console cannot read properties of undefined (QueryClient) I have declared the variable let queryclient = new QueryClient(), Just dont know what's wrong in here Thanks!...