TanStackT
TanStack•2y ago•
7 replies
urgent-maroon

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();
    }
  }
Was this page helpful?