T
TanStack•16mo ago
wise-white

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
wise-white
wise-white•16mo ago
#svelte-query-questions
wise-white
wise-whiteOP•16mo ago
So sorry. I didn't see that existed. My bad. Will delete here and repost thanks @M00LTi

Did you find this page helpful?