1
1
import type { IncomingMessage , ServerResponse } from 'http' ;
2
2
3
3
import type {
4
- ASTVisitor ,
5
4
DocumentNode ,
6
5
ValidationRule ,
7
- ValidationContext ,
8
6
ExecutionArgs ,
9
7
ExecutionResult ,
10
8
FormattedExecutionResult ,
@@ -15,7 +13,6 @@ import type {
15
13
} from 'graphql' ;
16
14
import accepts from 'accepts' ;
17
15
import httpError from 'http-errors' ;
18
- import type { HttpError } from 'http-errors' ;
19
16
import {
20
17
Source ,
21
18
GraphQLError ,
@@ -78,7 +75,7 @@ export interface OptionsData {
78
75
* An optional array of validation rules that will be applied on the document
79
76
* in additional to those defined by the GraphQL spec.
80
77
*/
81
- validationRules ?: ReadonlyArray < ( ctx : ValidationContext ) => ASTVisitor > ;
78
+ validationRules ?: ReadonlyArray < ValidationRule > ;
82
79
83
80
/**
84
81
* An optional function which will be used to validate instead of default `validate`
@@ -196,7 +193,7 @@ export function graphqlHTTP(options: Options): Middleware {
196
193
// Higher scoped variables are referred to at various stages in the asynchronous state machine below.
197
194
let params : GraphQLParams | undefined ;
198
195
let showGraphiQL = false ;
199
- let graphiqlOptions ;
196
+ let graphiqlOptions : GraphiQLOptions | undefined ;
200
197
let formatErrorFn = formatError ;
201
198
let pretty = false ;
202
199
let result : ExecutionResult ;
@@ -218,7 +215,7 @@ export function graphqlHTTP(options: Options): Middleware {
218
215
}
219
216
220
217
// Then, resolve the Options to get OptionsData.
221
- const optionsData : OptionsData = await resolveOptions ( params ) ;
218
+ const optionsData = await resolveOptions ( params ) ;
222
219
223
220
// Collect information from the options data object.
224
221
const schema = optionsData . schema ;
@@ -277,7 +274,7 @@ export function graphqlHTTP(options: Options): Middleware {
277
274
}
278
275
279
276
// Parse source to AST, reporting any syntax error.
280
- let documentAST ;
277
+ let documentAST : DocumentNode ;
281
278
try {
282
279
documentAST = parseFn ( new Source ( query , 'GraphQL request' ) ) ;
283
280
} catch ( syntaxError : unknown ) {
@@ -357,7 +354,7 @@ export function graphqlHTTP(options: Options): Middleware {
357
354
}
358
355
} catch ( rawError : unknown ) {
359
356
// If an error was caught, report the httpError status, or 500.
360
- const error : HttpError = httpError (
357
+ const error = httpError (
361
358
500 ,
362
359
/* istanbul ignore next: Thrown by underlying library. */
363
360
rawError instanceof Error ? rawError : String ( rawError ) ,
0 commit comments