I've a problem with apollo-link-error, I'm able to log the error but I would like show a modal with the error or display it on another page, is it possible without handling the error on each request ?
React, Apollo-client/server, https://github.com/kriasoft/react-starter-kit/tree/feature/apollo-pure
onError(({ graphQLErrors, networkError, response }) => {
console.log(graphQLErrors);
if (graphQLErrors) {
graphQLErrors.map(({message, locations, path, extensions}) => {
console.warn(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
);
if (extensions && extensions.exception && (extensions.exception.code === 16 || extensions.code === 'UNAUTHENTICATED')) {
// UNAUTHENTICATED
response.errors = null;
history.push('/login');
}
});
}
if (networkError) console.warn(`[Network error]: ${networkError}`);
}),
For now, I can catch the error with an error boundary if it's happening while rendering and show it a pretty way. But when the error occurs after rendering, it's ignored