Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: improper parsed error checks

Andrew Bastin5fa6c6cdb3f5
diff --git a/packages/hoppscotch-app/helpers/backend/GQLClient.ts b/packages/hoppscotch-app/helpers/backend/GQLClient.ts
index 7ca2d450c..5af67c7d2 100644
--- a/packages/hoppscotch-app/helpers/backend/GQLClient.ts
+++ b/packages/hoppscotch-app/helpers/backend/GQLClient.ts
@@ -201,7 +201,7 @@ export const useGQLQuery = <DocType, DocVarType, DocErrorType extends string>(
(gqlErr) =>
<GQLError<DocErrorType>>{
type: "gql_error",
- error: gqlErr as DocErrorType,
+ error: parseGQLErrorString(gqlErr ?? "") as DocErrorType,
},
// The right case (it was a GraphQL Error)
(networkErr) =>
@@ -244,6 +244,8 @@ export const useGQLQuery = <DocType, DocVarType, DocErrorType extends string>(
return response
}
+const parseGQLErrorString = (s: string) => s.startsWith("[GraphQL] ") ? s.split("[GraphQL] ")[1] : s
+
export const runMutation = <
DocType,
DocVariables extends object | undefined,