diff --git a/src/hooks/makeMutation.ts b/src/hooks/makeMutation.ts index 1bda2b926..0bd2c2eb5 100644 --- a/src/hooks/makeMutation.ts +++ b/src/hooks/makeMutation.ts @@ -50,7 +50,7 @@ function makeMutation( notify({ text: intl.formatMessage(commonMessages.readOnly) }); - } else if (err.graphQLErrors.every(isJwtError)) { + } else if (err.graphQLErrors.some(isJwtError)) { user.logout(); notify({ text: intl.formatMessage(commonMessages.sessionExpired) diff --git a/src/hooks/makeQuery.ts b/src/hooks/makeQuery.ts index e5ff1703c..beddd14df 100644 --- a/src/hooks/makeQuery.ts +++ b/src/hooks/makeQuery.ts @@ -64,7 +64,7 @@ function makeQuery( }, [queryData.loading]); if (queryData.error) { - if (queryData.error.graphQLErrors.every(isJwtError)) { + if (queryData.error.graphQLErrors.some(isJwtError)) { user.logout(); notify({ text: intl.formatMessage(commonMessages.sessionExpired) diff --git a/src/mutations.tsx b/src/mutations.tsx index 727a9d8e0..f685c6cb8 100644 --- a/src/mutations.tsx +++ b/src/mutations.tsx @@ -6,7 +6,7 @@ import { useIntl } from "react-intl"; import useNotifier from "./hooks/useNotifier"; import { commonMessages } from "./intl"; -import { maybe, getMutationStatus } from "./misc"; +import { getMutationStatus } from "./misc"; import { MutationResultAdditionalProps } from "./types"; import { isJwtError } from "./auth/errors"; import useUser from "./hooks/useUser"; @@ -37,17 +37,19 @@ export function TypedMutation( mutation={mutation} onCompleted={onCompleted} onError={(err: ApolloError) => { + if (err.networkError) { + notify({ + text: intl.formatMessage(commonMessages.somethingWentWrong) + }); + } if ( - maybe( - () => - err.graphQLErrors[0].extensions.exception.code === - "ReadOnlyException" - ) + err.graphQLErrors[0].extensions.exception?.code === + "ReadOnlyException" ) { notify({ text: intl.formatMessage(commonMessages.readOnly) }); - } else if (err.graphQLErrors.every(isJwtError)) { + } else if (err.graphQLErrors.some(isJwtError)) { user.logout(); notify({ text: intl.formatMessage(commonMessages.sessionExpired) diff --git a/src/queries.tsx b/src/queries.tsx index 952c943d8..708aa27b1 100644 --- a/src/queries.tsx +++ b/src/queries.tsx @@ -83,7 +83,7 @@ export function TypedQuery( > {(queryData: QueryResult) => { if (queryData.error) { - if (queryData.error.graphQLErrors.every(isJwtError)) { + if (queryData.error.graphQLErrors.some(isJwtError)) { user.logout(); notify({ text: intl.formatMessage(commonMessages.sessionExpired)