@@ -215,17 +215,9 @@ function graphqlHTTP(options: Options): Middleware {
215
215
// Then, resolve the Options to get OptionsData.
216
216
return resolveOptions ( params ) ;
217
217
} ,
218
- ( error ) => {
219
- // When we failed to parse the GraphQL parameters, we still need to get
220
- // the options object, so make an options call to resolve just that.
221
- const dummyParams = {
222
- query : null ,
223
- variables : null ,
224
- operationName : null ,
225
- raw : null ,
226
- } ;
227
- return resolveOptions ( dummyParams ) . then ( ( ) => Promise . reject ( error ) ) ;
228
- } ,
218
+ // When we failed to parse the GraphQL parameters, we still need to get
219
+ // the options object, so make an options call to resolve just that.
220
+ ( error ) => resolveOptions ( ) . then ( ( ) => Promise . reject ( error ) ) ,
229
221
)
230
222
. then ( ( optionsData ) => {
231
223
// Assert that schema is required.
@@ -402,7 +394,7 @@ function graphqlHTTP(options: Options): Middleware {
402
394
}
403
395
} ) ;
404
396
405
- async function resolveOptions ( requestParams ) {
397
+ async function resolveOptions ( requestParams ?: GraphQLParams ) {
406
398
const optionsResult =
407
399
typeof options === 'function'
408
400
? options ( request , response , requestParams )
@@ -438,10 +430,10 @@ function graphqlHTTP(options: Options): Middleware {
438
430
}
439
431
440
432
export type GraphQLParams = { |
441
- query : ? string ,
442
- variables : ? { + [ name : string ] : mixed , ... } ,
443
- operationName : ? string ,
444
- raw : ? boolean ,
433
+ query : string | null ,
434
+ variables : { + [ name : string ] : mixed , ... } | null ,
435
+ operationName : string | null ,
436
+ raw : boolean ,
445
437
| } ;
446
438
447
439
/**
@@ -496,9 +488,8 @@ function parseGraphQLParams(
496
488
* Helper function to determine if GraphiQL can be displayed.
497
489
*/
498
490
function canDisplayGraphiQL ( request : $Request , params : GraphQLParams ) : boolean {
499
- // If `raw` exists, GraphiQL mode is not enabled.
500
- // Allowed to show GraphiQL if not requested as raw and this request
501
- // prefers HTML over JSON.
491
+ // If `raw` false, GraphiQL mode is not enabled.
492
+ // Allowed to show GraphiQL if not requested as raw and this request prefers HTML over JSON.
502
493
return ! params . raw && accepts ( request ) . types ( [ 'json' , 'html' ] ) === 'html' ;
503
494
}
504
495
0 commit comments