@@ -19,7 +19,7 @@ import {
19
19
export = graphqlHTTP ;
20
20
21
21
type Request = IncomingMessage ;
22
- type Response = ServerResponse ;
22
+ type Response = ServerResponse & { json ?: ( data : unknown ) => void } ;
23
23
24
24
declare namespace graphqlHTTP {
25
25
/**
@@ -44,7 +44,7 @@ declare namespace graphqlHTTP {
44
44
* query exists from a previous session. If undefined is provided, GraphiQL
45
45
* will use its own default query.
46
46
*/
47
- defaultQuery : string ;
47
+ defaultQuery ? : string ;
48
48
}
49
49
50
50
interface OptionsData {
@@ -66,54 +66,50 @@ declare namespace graphqlHTTP {
66
66
/**
67
67
* A boolean to configure whether the output should be pretty-printed.
68
68
*/
69
- pretty ?: boolean | null ;
69
+ pretty ?: boolean ;
70
70
71
71
/**
72
72
* An optional array of validation rules that will be applied on the document
73
73
* in additional to those defined by the GraphQL spec.
74
74
*/
75
- validationRules ?: ReadonlyArray <
76
- ( ctx : ValidationContext ) => ASTVisitor
77
- > | null ;
75
+ validationRules ?: ReadonlyArray < ( ctx : ValidationContext ) => ASTVisitor > ;
78
76
79
77
/**
80
78
* An optional function which will be used to validate instead of default `validate`
81
79
* from `graphql-js`.
82
80
*/
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 > ;
90
86
91
87
/**
92
88
* An optional function which will be used to execute instead of default `execute`
93
89
* from `graphql-js`.
94
90
*/
95
- customExecuteFn ?:
96
- | ( ( args : ExecutionArgs ) => ExecutionResult | Promise < ExecutionResult > )
97
- | null ;
91
+ customExecuteFn ?: (
92
+ args : ExecutionArgs ,
93
+ ) => ExecutionResult | Promise < ExecutionResult > ;
98
94
99
95
/**
100
96
* An optional function which will be used to format any errors produced by
101
97
* fulfilling a GraphQL operation. If no function is provided, GraphQL's
102
98
* default spec-compliant `formatError` function will be used.
103
99
*/
104
- customFormatErrorFn ?: ( ( error : GraphQLError ) => unknown ) | null ;
100
+ customFormatErrorFn ?: ( error : GraphQLError ) => unknown ;
105
101
106
102
/**
107
103
* An optional function which will be used to create a document instead of
108
104
* the default `parse` from `graphql-js`.
109
105
*/
110
- customParseFn ?: ( source : Source ) => DocumentNode | null ;
106
+ customParseFn ?: ( source : Source ) => DocumentNode ;
111
107
112
108
/**
113
109
* `formatError` is deprecated and replaced by `customFormatErrorFn`. It will
114
110
* be removed in version 1.0.0.
115
111
*/
116
- formatError ?: ( ( error : GraphQLError ) => unknown ) | null ;
112
+ formatError ?: ( error : GraphQLError ) => unknown ;
117
113
118
114
/**
119
115
* An optional function for adding additional metadata to the GraphQL response
@@ -125,7 +121,7 @@ declare namespace graphqlHTTP {
125
121
*
126
122
* This function may be async.
127
123
*/
128
- extensions ?: ( ( info : RequestInfo ) => { [ key : string ] : unknown } ) | null ;
124
+ extensions ?: ( info : RequestInfo ) => { [ key : string ] : unknown } ;
129
125
130
126
/**
131
127
* A boolean to optionally enable GraphiQL mode.
@@ -138,14 +134,14 @@ declare namespace graphqlHTTP {
138
134
* If not provided, the default field resolver is used (which looks for a
139
135
* value or method on the source value with the field's name).
140
136
*/
141
- fieldResolver ?: GraphQLFieldResolver < unknown , unknown > | null ;
137
+ fieldResolver ?: GraphQLFieldResolver < unknown , unknown > ;
142
138
143
139
/**
144
140
* A type resolver function to use when none is provided by the schema.
145
141
* If not provided, the default type resolver is used (which looks for a
146
142
* `__typename` field or alternatively calls the `isTypeOf` method).
147
143
*/
148
- typeResolver ?: GraphQLTypeResolver < unknown , unknown > | null ;
144
+ typeResolver ?: GraphQLTypeResolver < unknown , unknown > ;
149
145
}
150
146
151
147
/**
@@ -155,17 +151,17 @@ declare namespace graphqlHTTP {
155
151
/**
156
152
* The parsed GraphQL document.
157
153
*/
158
- document : DocumentNode | null | undefined ;
154
+ document : DocumentNode ;
159
155
160
156
/**
161
157
* The variable values used at runtime.
162
158
*/
163
- variables : { readonly [ name : string ] : unknown } | null | undefined ;
159
+ variables : { readonly [ name : string ] : unknown } ;
164
160
165
161
/**
166
162
* The (optional) operation name requested.
167
163
*/
168
- operationName : string | null | undefined ;
164
+ operationName : string ;
169
165
170
166
/**
171
167
* The result of executing the operation.
@@ -178,16 +174,13 @@ declare namespace graphqlHTTP {
178
174
context ?: unknown ;
179
175
}
180
176
181
- type Middleware = (
182
- request : Request ,
183
- response : Response ,
184
- ) => Promise < undefined > ;
177
+ type Middleware = ( request : Request , response : Response ) => Promise < void > ;
185
178
186
179
interface GraphQLParams {
187
180
query : string | null ;
188
181
variables : { readonly [ name : string ] : unknown } | null ;
189
182
operationName : string | null ;
190
- raw : boolean | null ;
183
+ raw : boolean ;
191
184
}
192
185
}
193
186
0 commit comments