You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am unsure if this is a Tanstack question or Vue/Nuxt, so forgive me if this is not the right place for my question.
According to the Tanstack Query documentation, a query can be fetched during SSR by calling the suspense function provided by useQuery in the onServerPrefetch hook. Sadly the documentation does not specify the preferred way to call multiple suspense functions in the same component/route.
Another option would be multiple onServerPrefetch. I have not tried it, but I would guess it depends on how onServerPrefetch is implemented (calling each onServerPrefetch sequentially or using something like Promie#all), if it is even supported.
The third option would be to use Promise#all. Promise#all rejects if a single of the promises raises an error, which could help to find issues, but it would be pretty annoying if successful requests are thrown away (?).
Promise#allSettled seems like the best option since it does not reject if a single promise is unsuccessful, but I am not sure if I am missing something.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am unsure if this is a Tanstack question or Vue/Nuxt, so forgive me if this is not the right place for my question.
According to the Tanstack Query documentation, a query can be fetched during SSR by calling the
suspense
function provided byuseQuery
in theonServerPrefetch
hook. Sadly the documentation does not specify the preferred way to call multiplesuspense
functions in the same component/route.Assuming our code looks something like this:
We would have a lot of different options, but I am unsure which one to use.
The most obvious option is of course sequentially, but that is pretty easy to rule out as slower than the others.
Another option would be multiple
onServerPrefetch
. I have not tried it, but I would guess it depends on howonServerPrefetch
is implemented (calling eachonServerPrefetch
sequentially or using something likePromie#all
), if it is even supported.The third option would be to use
Promise#all
.Promise#all
rejects if a single of the promises raises an error, which could help to find issues, but it would be pretty annoying if successful requests are thrown away (?).Promise#allSettled
seems like the best option since it does not reject if a single promise is unsuccessful, but I am not sure if I am missing something.Beta Was this translation helpful? Give feedback.
All reactions