-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Hi,
I've been testing the new Apollo Client v4 in an enterprise Angular app, and I want to start by saying great work so far on the new changes, to name a few:
- The migration of Observables to RxJS, espcially for Angular, as it provides a much more seamless intergration.
watchQueryobservable no longer terminating on errors.- More consistent typing across the library.
On the other hand, one area that I found a bit more challenging to migrate was error handling, and I had some feedback if you don't mind me sharing:
Default error message
Currently, it's common to use apollo.watchQuery in a component and simply display result.error.message. I noticed the error message has changed, for example:
v3:
Email address is already in use
v4:
The GraphQL server returned with errors:
- Email address is already in use
My guess, and I might be wrong, most developers would probably choose to hide that part of the message, for example in our case, almost all of our end users don't know what GraphQL is and that to me feels like an implementation detail.
I know, the solution is simple, to call a formatError function, or implement onError link and wrap it in a new error type with a formatted message, but that introduces overhead and complexity in the app, for what I believe should be the default behavior. I'm keen to hear your thoughts on this?
Network errors
I noticed ApolloError has been replaced by multiple new error types, for the most part it's a welcome change.
The only challenge I found with the new types is that it's hard to distinguish a network error from other errors thrown in the app, this is especially challenging when an ApolloClient operation is only one part of a more complex async flow, it used to be easy to do an ApolloError.networkError check then, for example, decide to retry the operation. But now, and I might be missing something here, there's no simple reliable way of doing that anymore? I'd appreciate some suggestions.
Thanks.