Skip to content

Commit 1e25c4f

Browse files
committed
handler: renames customFormatter to formatErrorFn for consistency
1 parent 4c383a0 commit 1e25c4f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

handler.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ type Handler struct {
2828
playground bool
2929
rootObjectFn RootObjectFn
3030
resultCallbackFn ResultCallbackFn
31-
customErrorFormatter func(err error) gqlerrors.FormattedError
31+
formatErrorFn func(err error) gqlerrors.FormattedError
3232
}
33+
3334
type RequestOptions struct {
3435
Query string `json:"query" url:"query" schema:"query"`
3536
Variables map[string]interface{} `json:"variables" url:"variables" schema:"variables"`
@@ -128,21 +129,21 @@ func (h *Handler) ContextHandler(ctx context.Context, w http.ResponseWriter, r *
128129

129130
// execute graphql query
130131
params := graphql.Params{
131-
Schema: *h.Schema,
132-
RequestString: opts.Query,
133-
VariableValues: opts.Variables,
134-
OperationName: opts.OperationName,
135-
Context: ctx,
132+
Schema: *h.Schema,
133+
RequestString: opts.Query,
134+
VariableValues: opts.Variables,
135+
OperationName: opts.OperationName,
136+
Context: ctx,
136137
}
137138
if h.rootObjectFn != nil {
138139
params.RootObject = h.rootObjectFn(ctx, r)
139140
}
140141
result := graphql.Do(params)
141142

142-
if customFormatter := h.customErrorFormatter; customFormatter != nil {
143+
if formatErrorFn := h.formatErrorFn; formatErrorFn != nil {
143144
formatted := make([]gqlerrors.FormattedError, len(result.Errors))
144145
for i, err := range result.Errors {
145-
formatted[i] = customFormatter(err.OriginalError())
146+
formatted[i] = formatErrorFn(err.OriginalError())
146147
}
147148
result.Errors = formatted
148149
}
@@ -201,7 +202,7 @@ type Config struct {
201202
Playground bool
202203
RootObjectFn RootObjectFn
203204
ResultCallbackFn ResultCallbackFn
204-
CustomErrorFormatter func(err error) gqlerrors.FormattedError
205+
FormatErrorFn func(err error) gqlerrors.FormattedError
205206
}
206207

207208
func NewConfig() *Config {
@@ -229,6 +230,6 @@ func New(p *Config) *Handler {
229230
playground: p.Playground,
230231
rootObjectFn: p.RootObjectFn,
231232
resultCallbackFn: p.ResultCallbackFn,
232-
customErrorFormatter: p.CustomErrorFormatter,
233+
formatErrorFn: p.FormatErrorFn,
233234
}
234235
}

0 commit comments

Comments
 (0)