@@ -28,8 +28,9 @@ type Handler struct {
28
28
playground bool
29
29
rootObjectFn RootObjectFn
30
30
resultCallbackFn ResultCallbackFn
31
- customErrorFormatter func (err error ) gqlerrors.FormattedError
31
+ formatErrorFn func (err error ) gqlerrors.FormattedError
32
32
}
33
+
33
34
type RequestOptions struct {
34
35
Query string `json:"query" url:"query" schema:"query"`
35
36
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 *
128
129
129
130
// execute graphql query
130
131
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 ,
136
137
}
137
138
if h .rootObjectFn != nil {
138
139
params .RootObject = h .rootObjectFn (ctx , r )
139
140
}
140
141
result := graphql .Do (params )
141
142
142
- if customFormatter := h .customErrorFormatter ; customFormatter != nil {
143
+ if formatErrorFn := h .formatErrorFn ; formatErrorFn != nil {
143
144
formatted := make ([]gqlerrors.FormattedError , len (result .Errors ))
144
145
for i , err := range result .Errors {
145
- formatted [i ] = customFormatter (err .OriginalError ())
146
+ formatted [i ] = formatErrorFn (err .OriginalError ())
146
147
}
147
148
result .Errors = formatted
148
149
}
@@ -201,7 +202,7 @@ type Config struct {
201
202
Playground bool
202
203
RootObjectFn RootObjectFn
203
204
ResultCallbackFn ResultCallbackFn
204
- CustomErrorFormatter func (err error ) gqlerrors.FormattedError
205
+ FormatErrorFn func (err error ) gqlerrors.FormattedError
205
206
}
206
207
207
208
func NewConfig () * Config {
@@ -229,6 +230,6 @@ func New(p *Config) *Handler {
229
230
playground : p .Playground ,
230
231
rootObjectFn : p .RootObjectFn ,
231
232
resultCallbackFn : p .ResultCallbackFn ,
232
- customErrorFormatter : p . CustomErrorFormatter ,
233
+ formatErrorFn : p . FormatErrorFn ,
233
234
}
234
235
}
0 commit comments