From 0c29886812576e8cb94662c486b74ef74793f86f Mon Sep 17 00:00:00 2001 From: Florian BOUILLON Date: Thu, 29 Feb 2024 15:12:39 +0100 Subject: [PATCH] fix: better error logging for GraphQL Signed-off-by: Florian BOUILLON --- server/src/V2/graphql/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/V2/graphql/index.ts b/server/src/V2/graphql/index.ts index fe19359cc..a569be0e6 100644 --- a/server/src/V2/graphql/index.ts +++ b/server/src/V2/graphql/index.ts @@ -19,9 +19,14 @@ function graphQLErrorHandle(error: GraphQLError) { console.error(error) } if (error.source) { + const columns = (process?.stdout?.columns ?? 32) - 7 + const dashes = ''.padEnd(columns / 2, '-') + + console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`) console.error('GraphQL Error') console.error(error.message) - console.error(error.source?.body.replace(/\n/g, '\\n')) + console.error(error.source?.body) + console.error(`\x1b[91m${dashes} ERROR ${dashes}\x1b[0m`) } return formatError(error) }