@@ -22,7 +22,9 @@ describe('batch execution', () => {
22
22
field1: String
23
23
field2: String
24
24
field3(input: String): String
25
+ fieldNonNullable: String!
25
26
boom(message: String): String
27
+ boomNonNullable(message: String): String!
26
28
boomWithPath(message: String, path: [String]): String
27
29
extension: String
28
30
widget: Widget
@@ -37,6 +39,7 @@ describe('batch execution', () => {
37
39
field2 : ( ) => '2' ,
38
40
field3 : ( _root , { input } ) => String ( input ) ,
39
41
boom : ( _root , { message } ) => new Error ( message ) ,
42
+ boomNonNullable : ( _root , { message } ) => new Error ( message ) ,
40
43
boomWithPath : ( _root , { message, path } ) =>
41
44
createGraphQLError ( message , { path } ) ,
42
45
extension : ( ) => createGraphQLError ( 'boom' , { extensions } ) ,
@@ -231,6 +234,35 @@ describe('batch execution', () => {
231
234
expect ( executorCalls ) . toEqual ( 1 ) ;
232
235
} ) ;
233
236
237
+ it ( 'returns error for the failing non-nullable field' , async ( ) => {
238
+ const [ first ] = ( await Promise . all ( [
239
+ batchExec ( {
240
+ document : parse (
241
+ '{ fieldNonNullable boomNonNullable(message: "failed") }' ,
242
+ ) ,
243
+ } ) ,
244
+ ] ) ) as ExecutionResult [ ] ;
245
+
246
+ expect ( first ?. data ) . toBeNull ( ) ;
247
+ expect ( first ?. errors ?. length ) . toEqual ( 1 ) ;
248
+ expect ( first ?. errors ?. [ 0 ] ?. message ) . toMatch ( / f a i l e d / ) ;
249
+ expect ( executorCalls ) . toEqual ( 1 ) ;
250
+ } ) ;
251
+
252
+ it ( 'returns error for the failing non-nullable field across multiple executions' , async ( ) => {
253
+ const [ first , second ] = ( await Promise . all ( [
254
+ batchExec ( { document : parse ( '{ fieldNonNullable }' ) } ) ,
255
+ batchExec ( { document : parse ( '{ boomNonNullable(message: "failed") }' ) } ) ,
256
+ ] ) ) as ExecutionResult [ ] ;
257
+
258
+ expect ( first ?. data ) . toBeNull ( ) ;
259
+ expect ( first ?. errors ) . toBeUndefined ( ) ;
260
+ expect ( second ?. data ) . toBeNull ( ) ;
261
+ expect ( second ?. errors ?. length ) . toEqual ( 1 ) ;
262
+ expect ( second ?. errors ?. [ 0 ] ?. message ) . toMatch ( / f a i l e d / ) ;
263
+ expect ( executorCalls ) . toEqual ( 1 ) ;
264
+ } ) ;
265
+
234
266
it ( 'pathed errors contain extensions' , async ( ) => {
235
267
const [ first ] = ( await Promise . all ( [
236
268
batchExec ( { document : parse ( '{ extension }' ) } ) ,
0 commit comments