-
Notifications
You must be signed in to change notification settings - Fork 786
SSR should handle query errors #406
Comments
@tmeasday I lean towards option b though I think there is still some questions around error handling in general.
I don't fully understand this:
|
I would be inclined to not overthink it; it's unlikely a page has more than one or two queries (and they probably are going to all fire straightaway), so firing off extra queries on 404 is probably not a big problem. Plus it's like a misconfiguration problem rather than something that would happen in production. So I think we treat each query separately.
I tend to agree with this.
Oh, I realise now that I was thinking about it wrong. The "result" of What will AC do if you run a query that has previously network errored (in the rendering phase of SSR)? I suspect it may try and send the query again, which is not what we want. (Will report back) |
Hmm, OK trying a few things with AC, it doesn't seem like if you:
There is anyway for 2. to return an error without making another network request. If you pass @stubailo / @helfer I suspect what we want here (for two different |
Any updates? |
For a short term solution, could we simply adopt @tmeasday's suggestion of doing:
And make do with the additional network request? ATM causing the whole app to crash on a resolver error (e.g. user not authorised) isn't ideal for SSR! |
@benhjames I think you are right; I got hung up on trying to figure out a solution that didn't involve an redundant request but we should just fix the actual problem. Sorry about the delay here folks, I'll take a look at this today. |
See #406. We still end up rendering a loading screen but that is better than just bailing out of SSR completely.
Fixed in 1.0.0-rc.3 🎉 You still have to handle errors, but now we won’t stop resolving errors just because one rejected. |
See #404
If your server throws an error for a query, then AC will throw an
ApolloError
, but it will be unhandled by this line: https://github.com/apollostack/react-apollo/blob/master/src/server.ts#L131We could either
a) try and handle the error on that line (by catching the exception), and maybe just not recursing.
OR, we could
b) handle the error here: https://github.com/apollostack/react-apollo/blob/master/src/graphql.tsx#L361:
and thus allowing the subtree to render in the error state.
I guess (b) is more correct, although maybe more complicated in that we need to keep the error "rendering" behaviour in sync between
fetchData
andrender
, which is maybe wasted effort given that it seems unlikely they are going to fetch any more queries in their error handling rendering (and that's the only reason to keep recursing on the server).OTOH if we don't do it I think there'll be the occasional problem people run into where the different behaviour confuses them.
What do you think @jbaxleyiii?
The text was updated successfully, but these errors were encountered: