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'm an Apollo Client maintainer. I'd like to start a discussion in regards to error handling when using Apollo Client with Nuxt/h3 and see if we can collaborate on a solution.
We recently had this issue opened in our repo noting that network errors thrown by Apollo Client aren't forwarding the status code to h3's underlying H3Error due to how the status code is parsed in h3's error creation functions. It appears createError expects a statusCode property in order to set this on the H3Error instance. Unfortunately this doesn't integrate well with Apollo Client because Apollo Client wraps all errors in its own ApolloError instance. The status code is lost since the status code is instead found in error.networkError.statusCode.
I'd love to contribute a way to allow for these libraries to work better together. Unfortunately we are stuck with this error structure for the foreseeable future and we'd like to avoid adding a statusCode property to ApolloError itself, especially since Apollo Client's core aims to be framework agnostic.
One potential solution is that we could add a cause from ApolloError to the original error. With this perhaps createError could try to parse status/statusCode from error.cause if its available?
I'd love to get your thoughts on this! At the very least, perhaps a recommendation I could take back to the original issue would be useful. I'll be honest, I'm pretty unfamiliar with Nuxt/h3, so any help would be appreciated. Thanks!
Additional information
Would you be willing to help implement this feature?
The text was updated successfully, but these errors were encountered:
One potential solution is that we could add a cause from ApolloError to the original error. With this perhaps createError could try to parse status/statusCode from error.cause if its available?
This sound a good idea if cause.statusCode is available this way also h3 does not needs to add framework specific logic.
Glad to hear this idea is on the right track! I've got some priorities I need to get to this week, but I'm hoping I can contribute a PR for this in h3 sometime soon.
Describe the feature
Hey there 👋
I'm an Apollo Client maintainer. I'd like to start a discussion in regards to error handling when using Apollo Client with Nuxt/h3 and see if we can collaborate on a solution.
We recently had this issue opened in our repo noting that network errors thrown by Apollo Client aren't forwarding the status code to h3's underlying
H3Error
due to how the status code is parsed in h3's error creation functions. It appearscreateError
expects astatusCode
property in order to set this on theH3Error
instance. Unfortunately this doesn't integrate well with Apollo Client because Apollo Client wraps all errors in its ownApolloError
instance. The status code is lost since the status code is instead found inerror.networkError.statusCode
.I'd love to contribute a way to allow for these libraries to work better together. Unfortunately we are stuck with this error structure for the foreseeable future and we'd like to avoid adding a
statusCode
property toApolloError
itself, especially since Apollo Client's core aims to be framework agnostic.One potential solution is that we could add a
cause
fromApolloError
to the original error. With this perhapscreateError
could try to parsestatus
/statusCode
fromerror.cause
if its available?I'd love to get your thoughts on this! At the very least, perhaps a recommendation I could take back to the original issue would be useful. I'll be honest, I'm pretty unfamiliar with Nuxt/h3, so any help would be appreciated. Thanks!
Additional information
The text was updated successfully, but these errors were encountered: