apollographql / apollo-link

:link: Interface for fetching and modifying control flow of GraphQL requests
https://www.apollographql.com/docs/link/
MIT License
1.44k stars 344 forks source link

Apollo link error modify error returned in components #1049

Open sami616 opened 5 years ago

sami616 commented 5 years ago

Is there anyway for me to modify the shape of the errors which are passed to my components using apollo-link-error?

I tried manually setting the response.error object but didn't have any luck.

Is this possible?

sontd-0882 commented 4 years ago

Same issue here. I want to wrap the error object into an Error instance before forwarding (just like Afterware (data manipulation)) to the component but it doesn't work.


return forward(operation).map((response) => {
  if (response.errors) {
    response.data = new BaseError(graphQLErrors);
  }
  return response;
});