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

Commit 3ede973

Browse files
danielreardenIvanGoncharov
authored andcommitted
Sync TS typings with Flow typings
1 parent 81c7986 commit 3ede973

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

types/index.d.ts

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
export = graphqlHTTP;
2020

2121
type Request = IncomingMessage;
22-
type Response = ServerResponse;
22+
type Response = ServerResponse & { json?: (data: unknown) => void };
2323

2424
declare namespace graphqlHTTP {
2525
/**
@@ -44,7 +44,7 @@ declare namespace graphqlHTTP {
4444
* query exists from a previous session. If undefined is provided, GraphiQL
4545
* will use its own default query.
4646
*/
47-
defaultQuery: string;
47+
defaultQuery?: string;
4848
}
4949

5050
interface OptionsData {
@@ -66,54 +66,50 @@ declare namespace graphqlHTTP {
6666
/**
6767
* A boolean to configure whether the output should be pretty-printed.
6868
*/
69-
pretty?: boolean | null;
69+
pretty?: boolean;
7070

7171
/**
7272
* An optional array of validation rules that will be applied on the document
7373
* in additional to those defined by the GraphQL spec.
7474
*/
75-
validationRules?: ReadonlyArray<
76-
(ctx: ValidationContext) => ASTVisitor
77-
> | null;
75+
validationRules?: ReadonlyArray<(ctx: ValidationContext) => ASTVisitor>;
7876

7977
/**
8078
* An optional function which will be used to validate instead of default `validate`
8179
* from `graphql-js`.
8280
*/
83-
customValidateFn?:
84-
| ((
85-
schema: GraphQLSchema,
86-
documentAST: DocumentNode,
87-
rules: ReadonlyArray<ValidationRule>,
88-
) => ReadonlyArray<GraphQLError>)
89-
| null;
81+
customValidateFn?: (
82+
schema: GraphQLSchema,
83+
documentAST: DocumentNode,
84+
rules: ReadonlyArray<ValidationRule>,
85+
) => ReadonlyArray<GraphQLError>;
9086

9187
/**
9288
* An optional function which will be used to execute instead of default `execute`
9389
* from `graphql-js`.
9490
*/
95-
customExecuteFn?:
96-
| ((args: ExecutionArgs) => ExecutionResult | Promise<ExecutionResult>)
97-
| null;
91+
customExecuteFn?: (
92+
args: ExecutionArgs,
93+
) => ExecutionResult | Promise<ExecutionResult>;
9894

9995
/**
10096
* An optional function which will be used to format any errors produced by
10197
* fulfilling a GraphQL operation. If no function is provided, GraphQL's
10298
* default spec-compliant `formatError` function will be used.
10399
*/
104-
customFormatErrorFn?: ((error: GraphQLError) => unknown) | null;
100+
customFormatErrorFn?: (error: GraphQLError) => unknown;
105101

106102
/**
107103
* An optional function which will be used to create a document instead of
108104
* the default `parse` from `graphql-js`.
109105
*/
110-
customParseFn?: (source: Source) => DocumentNode | null;
106+
customParseFn?: (source: Source) => DocumentNode;
111107

112108
/**
113109
* `formatError` is deprecated and replaced by `customFormatErrorFn`. It will
114110
* be removed in version 1.0.0.
115111
*/
116-
formatError?: ((error: GraphQLError) => unknown) | null;
112+
formatError?: (error: GraphQLError) => unknown;
117113

118114
/**
119115
* An optional function for adding additional metadata to the GraphQL response
@@ -125,7 +121,7 @@ declare namespace graphqlHTTP {
125121
*
126122
* This function may be async.
127123
*/
128-
extensions?: ((info: RequestInfo) => { [key: string]: unknown }) | null;
124+
extensions?: (info: RequestInfo) => { [key: string]: unknown };
129125

130126
/**
131127
* A boolean to optionally enable GraphiQL mode.
@@ -138,14 +134,14 @@ declare namespace graphqlHTTP {
138134
* If not provided, the default field resolver is used (which looks for a
139135
* value or method on the source value with the field's name).
140136
*/
141-
fieldResolver?: GraphQLFieldResolver<unknown, unknown> | null;
137+
fieldResolver?: GraphQLFieldResolver<unknown, unknown>;
142138

143139
/**
144140
* A type resolver function to use when none is provided by the schema.
145141
* If not provided, the default type resolver is used (which looks for a
146142
* `__typename` field or alternatively calls the `isTypeOf` method).
147143
*/
148-
typeResolver?: GraphQLTypeResolver<unknown, unknown> | null;
144+
typeResolver?: GraphQLTypeResolver<unknown, unknown>;
149145
}
150146

151147
/**
@@ -155,17 +151,17 @@ declare namespace graphqlHTTP {
155151
/**
156152
* The parsed GraphQL document.
157153
*/
158-
document: DocumentNode | null | undefined;
154+
document: DocumentNode;
159155

160156
/**
161157
* The variable values used at runtime.
162158
*/
163-
variables: { readonly [name: string]: unknown } | null | undefined;
159+
variables: { readonly [name: string]: unknown };
164160

165161
/**
166162
* The (optional) operation name requested.
167163
*/
168-
operationName: string | null | undefined;
164+
operationName: string;
169165

170166
/**
171167
* The result of executing the operation.
@@ -178,16 +174,13 @@ declare namespace graphqlHTTP {
178174
context?: unknown;
179175
}
180176

181-
type Middleware = (
182-
request: Request,
183-
response: Response,
184-
) => Promise<undefined>;
177+
type Middleware = (request: Request, response: Response) => Promise<void>;
185178

186179
interface GraphQLParams {
187180
query: string | null;
188181
variables: { readonly [name: string]: unknown } | null;
189182
operationName: string | null;
190-
raw: boolean | null;
183+
raw: boolean;
191184
}
192185
}
193186

0 commit comments

Comments
 (0)