T
TanStack•14mo ago
extended-salmon

How to do dependent queries in svelte?

I can figure it out for the life of me 😦 best solution I have found is something like this:
let secondQuery = createQuery({
queryKey: ["s"],
queryFn: async () => {
...
},
enabled: () =>
!!$firstQuery.data &&
!$firstQuery.isFetching &&
!$firstQuery.isRefetching,
});

$: {
if ($firstQuery.isFetched && !$secondQuery.isFetched) {
$tleQuery.refetch();
}
}
let secondQuery = createQuery({
queryKey: ["s"],
queryFn: async () => {
...
},
enabled: () =>
!!$firstQuery.data &&
!$firstQuery.isFetching &&
!$firstQuery.isRefetching,
});

$: {
if ($firstQuery.isFetched && !$secondQuery.isFetched) {
$tleQuery.refetch();
}
}
2 Replies
exotic-emerald
exotic-emerald•14mo ago
#svelte-query-questions
extended-salmon
extended-salmonOP•14mo ago
So sorry. I didn't see that existed. My bad. Will delete here and repost thanks @M00LTi

Did you find this page helpful?