When will getDataFromTree throw errors/how can I tell if errors were encountered?

Hi,
I’d like a better understanding of getDataFromTree’s error policy and when I can expect it to throw errors. I’m trying to run getDataFromTree server-side in a NextJS app in getServerSideProps, and I think it might be hiding errors it encounters. The documentation doesn’t do a great job of explaining when I can expect getDataFromTree to throw an error (if ever). I guess what I’m asking - how can I get a good idea of whether my useQuery calls are returning errors during getDataFromTree? My default errorPolicy for my client is “All”.

Any help would be appreciated, thanks

It doesn’t. Internally, it just renders your React component - and that will never throw an error to the outside.

At the end of it running, you’ll have the data of all successful queries, and in the worst case (I assume), it will have to make the other queries in the browser again.

So, effectively what your saying is that there is no way of telling if my useQuery hooks return errors during the execution of getDataFromTree?

Hey @henryn :wave:

You should be able to look at the error property returned by useQuery, and if its populated, throw it yourself (if you want the throw behavior). See if that works for you!

Hey!
As stated above, it does not seem like any graphql errors is returned or thrown when running getDataFromTree. Ideally we would like to catch graphql errors server side so we can return a proper http response.

Say we’re rendering page /todo/todo-dont-exist which uses useQuery to fetch a todo. If the todo does not exist the error from useQuery would entail that. If that’s happening we would like to catch that so we could return a 404 server side. But this does not seem possible at the moment with getDataFromTree if I’m not missing anything?

If this is correct, would it be possible to add support for this, perhaps as an option to enable?