feat: invite system error states and user prompts

This commit is contained in:
liyasthomas
2021-10-21 18:17:32 +05:30
parent 5fa6c6cdb3
commit 6c64ffe833
6 changed files with 139 additions and 40 deletions

View File

@@ -201,7 +201,9 @@ export const useGQLQuery = <DocType, DocVarType, DocErrorType extends string>(
(gqlErr) =>
<GQLError<DocErrorType>>{
type: "gql_error",
error: parseGQLErrorString(gqlErr ?? "") as DocErrorType,
error: parseGQLErrorString(
gqlErr ?? ""
) as DocErrorType,
},
// The right case (it was a GraphQL Error)
(networkErr) =>
@@ -244,7 +246,8 @@ export const useGQLQuery = <DocType, DocVarType, DocErrorType extends string>(
return response
}
const parseGQLErrorString = (s: string) => s.startsWith("[GraphQL] ") ? s.split("[GraphQL] ")[1] : s
const parseGQLErrorString = (s: string) =>
s.startsWith("[GraphQL] ") ? s.split("[GraphQL] ")[1] : s
export const runMutation = <
DocType,
@@ -273,13 +276,13 @@ export const runMutation = <
// Result is null
pipe(
result.error?.networkError,
E.fromNullable(result.error?.name),
E.fromNullable(result.error?.message),
E.match(
// The left case (network error was null)
(gqlErr) =>
<GQLError<DocErrors>>{
type: "gql_error",
error: gqlErr,
error: parseGQLErrorString(gqlErr ?? ""),
},
// The right case (it was a network error)
(networkErr) =>