Skip to content

Commit 4c383a0

Browse files
racerxdlchris-ramon
authored andcommitted
Updated CustomErrorFormatter to use originalError
1 parent f127033 commit 4c383a0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

handler.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,20 @@ func (h *Handler) ContextHandler(ctx context.Context, w http.ResponseWriter, r *
133133
VariableValues: opts.Variables,
134134
OperationName: opts.OperationName,
135135
Context: ctx,
136-
CustomErrorFomatter: h.customErrorFormatter,
137136
}
138137
if h.rootObjectFn != nil {
139138
params.RootObject = h.rootObjectFn(ctx, r)
140139
}
141140
result := graphql.Do(params)
142141

142+
if customFormatter := h.customErrorFormatter; customFormatter != nil {
143+
formatted := make([]gqlerrors.FormattedError, len(result.Errors))
144+
for i, err := range result.Errors {
145+
formatted[i] = customFormatter(err.OriginalError())
146+
}
147+
result.Errors = formatted
148+
}
149+
143150
if h.graphiql {
144151
acceptHeader := r.Header.Get("Accept")
145152
_, raw := r.URL.Query()["raw"]

0 commit comments

Comments
 (0)