Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 9208833

Browse files
authored
fix: improve types (#753)
1 parent e02079c commit 9208833

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/index.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import type { IncomingMessage, ServerResponse } from 'http';
22

33
import type {
4-
ASTVisitor,
54
DocumentNode,
65
ValidationRule,
7-
ValidationContext,
86
ExecutionArgs,
97
ExecutionResult,
108
FormattedExecutionResult,
@@ -15,7 +13,6 @@ import type {
1513
} from 'graphql';
1614
import accepts from 'accepts';
1715
import httpError from 'http-errors';
18-
import type { HttpError } from 'http-errors';
1916
import {
2017
Source,
2118
GraphQLError,
@@ -78,7 +75,7 @@ export interface OptionsData {
7875
* An optional array of validation rules that will be applied on the document
7976
* in additional to those defined by the GraphQL spec.
8077
*/
81-
validationRules?: ReadonlyArray<(ctx: ValidationContext) => ASTVisitor>;
78+
validationRules?: ReadonlyArray<ValidationRule>;
8279

8380
/**
8481
* An optional function which will be used to validate instead of default `validate`
@@ -196,7 +193,7 @@ export function graphqlHTTP(options: Options): Middleware {
196193
// Higher scoped variables are referred to at various stages in the asynchronous state machine below.
197194
let params: GraphQLParams | undefined;
198195
let showGraphiQL = false;
199-
let graphiqlOptions;
196+
let graphiqlOptions: GraphiQLOptions | undefined;
200197
let formatErrorFn = formatError;
201198
let pretty = false;
202199
let result: ExecutionResult;
@@ -218,7 +215,7 @@ export function graphqlHTTP(options: Options): Middleware {
218215
}
219216

220217
// Then, resolve the Options to get OptionsData.
221-
const optionsData: OptionsData = await resolveOptions(params);
218+
const optionsData = await resolveOptions(params);
222219

223220
// Collect information from the options data object.
224221
const schema = optionsData.schema;
@@ -277,7 +274,7 @@ export function graphqlHTTP(options: Options): Middleware {
277274
}
278275

279276
// Parse source to AST, reporting any syntax error.
280-
let documentAST;
277+
let documentAST: DocumentNode;
281278
try {
282279
documentAST = parseFn(new Source(query, 'GraphQL request'));
283280
} catch (syntaxError: unknown) {
@@ -357,7 +354,7 @@ export function graphqlHTTP(options: Options): Middleware {
357354
}
358355
} catch (rawError: unknown) {
359356
// If an error was caught, report the httpError status, or 500.
360-
const error: HttpError = httpError(
357+
const error = httpError(
361358
500,
362359
/* istanbul ignore next: Thrown by underlying library. */
363360
rawError instanceof Error ? rawError : String(rawError),

0 commit comments

Comments
 (0)