Fix network error handling (#3406)
This commit is contained in:
parent
63b98a08bf
commit
935c224bb2
2 changed files with 6 additions and 2 deletions
|
@ -18,9 +18,9 @@ export const displayDemoMessage = (
|
|||
|
||||
const getNetworkErrors = (error: ApolloError): string[] => {
|
||||
const networkErrors = error.networkError as ServerError;
|
||||
|
||||
if (networkErrors) {
|
||||
// Apparently network errors can be an object or an array
|
||||
|
||||
if (Array.isArray(networkErrors.result)) {
|
||||
networkErrors.result.forEach(result => {
|
||||
if (result.errors) {
|
||||
|
@ -29,6 +29,10 @@ const getNetworkErrors = (error: ApolloError): string[] => {
|
|||
});
|
||||
}
|
||||
|
||||
if (networkErrors.result?.errors) {
|
||||
return networkErrors.result.errors.map(({ message }) => message);
|
||||
}
|
||||
|
||||
return [networkErrors.message];
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ export function useMutation<TData, TVariables>(
|
|||
},
|
||||
onError: (err: ApolloError) => {
|
||||
if (!disableErrorHandling) {
|
||||
if (err.graphQLErrors) {
|
||||
if (err?.graphQLErrors.length > 0) {
|
||||
if (hasError(err, GqlErrors.ReadOnlyException)) {
|
||||
notify({
|
||||
status: "error",
|
||||
|
|
Loading…
Reference in a new issue