@@ -234,20 +234,6 @@ function executeImpl(
234
234
return buildResponse(context, result);
235
235
}
236
236
237
- /**
238
- * Utility function to merge context's errors so far the errors in an
239
- * ExecutionPartialResult, zero the context's errors, and return the new
240
- * ExecutionPartialResult.
241
- */
242
- function mergeErrors (
243
- context : ExecutionContext ,
244
- result : ExecutionPartialResultNP < mixed > ,
245
- ): ExecutionPartialResultNP< mixed > {
246
- const errors = context . errors ;
247
- context . errors = [ ] ;
248
- return { data : result . data , errors : [ ...errors , ...( result . errors || [ ] ) ] } ;
249
- }
250
-
251
237
/**
252
238
* Given a completed execution context and data, build the { errors, data }
253
239
* response defined by the "Response" section of the GraphQL specification.
@@ -258,9 +244,7 @@ function buildResponse(
258
244
) {
259
245
const promise = getPromise ( result ) ;
260
246
if ( promise ) {
261
- return promise . then ( resolved =>
262
- buildResponse ( context , mergeErrors ( context , resolved ) ) ,
263
- ) ;
247
+ return promise . then ( resolved => buildResponse ( context , resolved ) ) ;
264
248
}
265
249
if ( result . data && ( ! result . errors || ! result . errors . length ) ) {
266
250
return { data : result . data } ;
@@ -435,13 +419,14 @@ function executeOperation(
435
419
: executeFields ( exeContext , type , rootValue , path , fields ) ;
436
420
const promise = getPromise ( result ) ;
437
421
if ( promise ) {
438
- return promise . then ( undefined , error =>
439
- mergeErrors ( exeContext , { data : null , errors : [ error ] } ) ,
440
- ) ;
422
+ return promise . then ( undefined , error => ( {
423
+ data : null ,
424
+ errors : [ error ] ,
425
+ } ) ) ;
441
426
}
442
- return mergeErrors ( exeContext , result ) ;
427
+ return result ;
443
428
} catch (error) {
444
- return mergeErrors ( exeContext , { data : null , errors : [ error ] } ) ;
429
+ return { data : null , errors : [ error ] } ;
445
430
}
446
431
}
447
432
@@ -582,7 +567,7 @@ function mergeEPRs(
582
567
( merged , value , i ) => {
583
568
merged . data [ keys [ i ] ] = value . data ;
584
569
if ( value . errors && value . errors . length ) {
585
- merged . errors . push . apply ( merged . errors , value . errors ) ;
570
+ merged . errors . push ( ... value . errors ) ;
586
571
}
587
572
return merged ;
588
573
} ,
@@ -1125,7 +1110,7 @@ function flattenEPRs(
1125
1110
forEach ( ( eprs : any ) , item => {
1126
1111
data . push ( item . data ) ;
1127
1112
if ( item . errors && item . errors . length ) {
1128
- errors . push . apply ( errors , item . errors ) ;
1113
+ errors . push ( ... item . errors ) ;
1129
1114
}
1130
1115
} ) ;
1131
1116
return { data , errors } ;
0 commit comments