DIsplay correct error if there were no gql errors
This commit is contained in:
parent
807f9c193b
commit
3a5791e796
4 changed files with 12 additions and 10 deletions
|
@ -50,7 +50,7 @@ function makeMutation<TData, TVariables>(
|
|||
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)
|
||||
|
|
|
@ -64,7 +64,7 @@ function makeQuery<TData, TVariables>(
|
|||
}, [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)
|
||||
|
|
|
@ -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<TData, TVariables>(
|
|||
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)
|
||||
|
|
|
@ -83,7 +83,7 @@ export function TypedQuery<TData, TVariables>(
|
|||
>
|
||||
{(queryData: QueryResult<TData, TVariables>) => {
|
||||
if (queryData.error) {
|
||||
if (queryData.error.graphQLErrors.every(isJwtError)) {
|
||||
if (queryData.error.graphQLErrors.some(isJwtError)) {
|
||||
user.logout();
|
||||
notify({
|
||||
text: intl.formatMessage(commonMessages.sessionExpired)
|
||||
|
|
Loading…
Reference in a new issue