@@ -115,15 +115,6 @@ export interface OptionsData {
115
115
*/
116
116
formatError ?: ( error : GraphQLError ) => GraphQLFormattedError ;
117
117
118
- /**
119
- * Use this to modify the response when a runtime query error occurs. By
120
- * default the statusCode will be set to 500.
121
- */
122
- handleRuntimeQueryErrorFn ?: (
123
- result : ExecutionResult ,
124
- response : Response ,
125
- ) => void ;
126
-
127
118
/**
128
119
* An optional function for adding additional metadata to the GraphQL response
129
120
* as a key-value object. The result will be added to "extensions" field in
@@ -209,7 +200,6 @@ export function graphqlHTTP(options: Options): Middleware {
209
200
let formatErrorFn = formatError ;
210
201
let pretty = false ;
211
202
let result : ExecutionResult ;
212
- let optionsData : OptionsData | undefined ;
213
203
214
204
try {
215
205
// Parse the Request to get GraphQL request parameters.
@@ -218,7 +208,7 @@ export function graphqlHTTP(options: Options): Middleware {
218
208
} catch ( error : unknown ) {
219
209
// When we failed to parse the GraphQL parameters, we still need to get
220
210
// the options object, so make an options call to resolve just that.
221
- optionsData = await resolveOptions ( ) ;
211
+ const optionsData = await resolveOptions ( ) ;
222
212
pretty = optionsData . pretty ?? false ;
223
213
formatErrorFn =
224
214
optionsData . customFormatErrorFn ??
@@ -228,7 +218,7 @@ export function graphqlHTTP(options: Options): Middleware {
228
218
}
229
219
230
220
// Then, resolve the Options to get OptionsData.
231
- optionsData = await resolveOptions ( params ) ;
221
+ const optionsData : OptionsData = await resolveOptions ( params ) ;
232
222
233
223
// Collect information from the options data object.
234
224
const schema = optionsData . schema ;
@@ -398,22 +388,13 @@ export function graphqlHTTP(options: Options): Middleware {
398
388
}
399
389
}
400
390
401
- if ( result . errors != null || result . data == null ) {
402
- const handleRuntimeQueryErrorFn =
403
- optionsData ?. handleRuntimeQueryErrorFn ??
404
- ( ( _result , _response ) => {
405
- // If no data was included in the result, that indicates a runtime query
406
- // error, indicate as such with a generic status code.
407
- // Note: Information about the error itself will still be contained in
408
- // the resulting JSON payload.
409
- // https://graphql.github.io/graphql-spec/#sec-Data
410
-
411
- if ( _response . statusCode === 200 && _result . data == null ) {
412
- _response . statusCode = 500 ;
413
- }
414
- } ) ;
415
-
416
- handleRuntimeQueryErrorFn ( result , response ) ;
391
+ // If no data was included in the result, that indicates a runtime query
392
+ // error, indicate as such with a generic status code.
393
+ // Note: Information about the error itself will still be contained in
394
+ // the resulting JSON payload.
395
+ // https://graphql.github.io/graphql-spec/#sec-Data
396
+ if ( response . statusCode === 200 && result . data == null ) {
397
+ response . statusCode = 500 ;
417
398
}
418
399
419
400
// Format any encountered errors.
0 commit comments