From 9a81c8eaff514e58995510c53da087711ed73826 Mon Sep 17 00:00:00 2001 From: Brad Reed Date: Mon, 16 Feb 2026 10:01:32 +0000 Subject: [PATCH 1/3] add cause property to graphql error logs --- src/GraphQL/Client/Query.js | 3 +++ src/GraphQL/Client/Query.purs | 4 ++++ 2 files changed, 7 insertions(+) create mode 100644 src/GraphQL/Client/Query.js diff --git a/src/GraphQL/Client/Query.js b/src/GraphQL/Client/Query.js new file mode 100644 index 0000000..f5960be --- /dev/null +++ b/src/GraphQL/Client/Query.js @@ -0,0 +1,3 @@ +export function cause(err) { + return String(err.cause || ""); +} diff --git a/src/GraphQL/Client/Query.purs b/src/GraphQL/Client/Query.purs index a320056..16b24d1 100644 --- a/src/GraphQL/Client/Query.purs +++ b/src/GraphQL/Client/Query.purs @@ -43,6 +43,8 @@ import GraphQL.Client.Types (class GqlQuery, class QueryClient, Client(..), GqlR import GraphQL.Client.Variables (class VarsTypeChecked, getVarsJson, getVarsTypeNames) import Type.Proxy (Proxy(..)) +foreign import cause :: Error -> String + -- | Run a graphQL query with a custom decoder and custom options queryOptsWithDecoder :: forall client directives schema query returns queryOpts mutationOpts sr @@ -261,6 +263,8 @@ addErrorInfo schema queryName q = <> show queryName <> ".\nerror: " <> message err + <> ".\ncause: " + <> cause err <> ".\nquery: " <> queryName <> " " From dcca416c881a3c7ba6a244a22ee625df03b0fd73 Mon Sep 17 00:00:00 2001 From: Brad Reed Date: Tue, 10 Mar 2026 20:54:31 +0800 Subject: [PATCH 2/3] add more info about errors in Query.js --- src/GraphQL/Client/Query.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/GraphQL/Client/Query.js b/src/GraphQL/Client/Query.js index f5960be..91cc075 100644 --- a/src/GraphQL/Client/Query.js +++ b/src/GraphQL/Client/Query.js @@ -1,3 +1,17 @@ -export function cause(err) { - return String(err.cause || ""); -} +const formatError = (err) => { + if (!err) return ""; + const props = ["message", "code", "syscall", "hostname", "address", "port"] + .filter((k) => err[k]) + .map((k) => `${k}: ${err[k]}`); + if (err.cause) props.push(`cause: ${formatError(err.cause)}`); + return props.join(", "); +}; + +export const cause = (err) => { + const c = err.cause; + if (!c) return ""; + if (c instanceof AggregateError) { + return [c.message, ...Array.from(c.errors, (e, i) => `[${i}] ${formatError(e)}`)].join("\n"); + } + return formatError(c); +}; From 9e2bf809ce5854f3e264dd45cc6ea24eb846a74c Mon Sep 17 00:00:00 2001 From: Brad Reed Date: Tue, 10 Mar 2026 20:56:01 +0800 Subject: [PATCH 3/3] Update src/GraphQL/Client/Query.js Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- src/GraphQL/Client/Query.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/GraphQL/Client/Query.js b/src/GraphQL/Client/Query.js index 91cc075..ae1329d 100644 --- a/src/GraphQL/Client/Query.js +++ b/src/GraphQL/Client/Query.js @@ -11,7 +11,10 @@ export const cause = (err) => { const c = err.cause; if (!c) return ""; if (c instanceof AggregateError) { - return [c.message, ...Array.from(c.errors, (e, i) => `[${i}] ${formatError(e)}`)].join("\n"); + return [ + c.message, + ...Array.from(c.errors, (e, i) => `[${i}] ${formatError(e)}`), + ].join("\n"); } return formatError(c); };