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({
|
notify({
|
||||||
text: intl.formatMessage(commonMessages.readOnly)
|
text: intl.formatMessage(commonMessages.readOnly)
|
||||||
});
|
});
|
||||||
} else if (err.graphQLErrors.every(isJwtError)) {
|
} else if (err.graphQLErrors.some(isJwtError)) {
|
||||||
user.logout();
|
user.logout();
|
||||||
notify({
|
notify({
|
||||||
text: intl.formatMessage(commonMessages.sessionExpired)
|
text: intl.formatMessage(commonMessages.sessionExpired)
|
||||||
|
|
|
@ -64,7 +64,7 @@ function makeQuery<TData, TVariables>(
|
||||||
}, [queryData.loading]);
|
}, [queryData.loading]);
|
||||||
|
|
||||||
if (queryData.error) {
|
if (queryData.error) {
|
||||||
if (queryData.error.graphQLErrors.every(isJwtError)) {
|
if (queryData.error.graphQLErrors.some(isJwtError)) {
|
||||||
user.logout();
|
user.logout();
|
||||||
notify({
|
notify({
|
||||||
text: intl.formatMessage(commonMessages.sessionExpired)
|
text: intl.formatMessage(commonMessages.sessionExpired)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import useNotifier from "./hooks/useNotifier";
|
import useNotifier from "./hooks/useNotifier";
|
||||||
import { commonMessages } from "./intl";
|
import { commonMessages } from "./intl";
|
||||||
import { maybe, getMutationStatus } from "./misc";
|
import { getMutationStatus } from "./misc";
|
||||||
import { MutationResultAdditionalProps } from "./types";
|
import { MutationResultAdditionalProps } from "./types";
|
||||||
import { isJwtError } from "./auth/errors";
|
import { isJwtError } from "./auth/errors";
|
||||||
import useUser from "./hooks/useUser";
|
import useUser from "./hooks/useUser";
|
||||||
|
@ -37,17 +37,19 @@ export function TypedMutation<TData, TVariables>(
|
||||||
mutation={mutation}
|
mutation={mutation}
|
||||||
onCompleted={onCompleted}
|
onCompleted={onCompleted}
|
||||||
onError={(err: ApolloError) => {
|
onError={(err: ApolloError) => {
|
||||||
|
if (err.networkError) {
|
||||||
|
notify({
|
||||||
|
text: intl.formatMessage(commonMessages.somethingWentWrong)
|
||||||
|
});
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
maybe(
|
err.graphQLErrors[0].extensions.exception?.code ===
|
||||||
() =>
|
"ReadOnlyException"
|
||||||
err.graphQLErrors[0].extensions.exception.code ===
|
|
||||||
"ReadOnlyException"
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
notify({
|
notify({
|
||||||
text: intl.formatMessage(commonMessages.readOnly)
|
text: intl.formatMessage(commonMessages.readOnly)
|
||||||
});
|
});
|
||||||
} else if (err.graphQLErrors.every(isJwtError)) {
|
} else if (err.graphQLErrors.some(isJwtError)) {
|
||||||
user.logout();
|
user.logout();
|
||||||
notify({
|
notify({
|
||||||
text: intl.formatMessage(commonMessages.sessionExpired)
|
text: intl.formatMessage(commonMessages.sessionExpired)
|
||||||
|
|
|
@ -83,7 +83,7 @@ export function TypedQuery<TData, TVariables>(
|
||||||
>
|
>
|
||||||
{(queryData: QueryResult<TData, TVariables>) => {
|
{(queryData: QueryResult<TData, TVariables>) => {
|
||||||
if (queryData.error) {
|
if (queryData.error) {
|
||||||
if (queryData.error.graphQLErrors.every(isJwtError)) {
|
if (queryData.error.graphQLErrors.some(isJwtError)) {
|
||||||
user.logout();
|
user.logout();
|
||||||
notify({
|
notify({
|
||||||
text: intl.formatMessage(commonMessages.sessionExpired)
|
text: intl.formatMessage(commonMessages.sessionExpired)
|
||||||
|
|
Loading…
Reference in a new issue