How to redirect from sub query
Hello there,
I'm trying to call a query within another query to avoid duplicate database calls. For example:
The issue is that when the user is not found in the session or database, the
If I look at the type of
What I expect is for
Interestingly, if I replace the inner query call with a server function like this:
Then it works as expected.
I'm trying to call a query within another query to avoid duplicate database calls. For example:
The issue is that when the user is not found in the session or database, the
getRedirectOrUserQuery function throws a redirect, but that exception is never received by getUser. Instead, getRedirectOrUserQuery returns undefined, and then getUser returns undefined.If I look at the type of
const user, it's inferred as non-nullable, but at runtime, it's actually undefined.What I expect is for
getRedirectOrUserQuery to throw a redirect, which should redirect the user and stop the execution of getUser.Interestingly, if I replace the inner query call with a server function like this:
Then it works as expected.
