8
8
import { expect } from 'chai' ;
9
9
import { describe , it } from 'mocha' ;
10
10
import { execute } from '../execute' ;
11
- import { formatError } from '../../error' ;
12
11
import { parse } from '../../language' ;
13
12
import {
14
13
GraphQLSchema ,
@@ -461,78 +460,79 @@ describe('Execute: Handles basic execution tasks', () => {
461
460
462
461
const result = await execute ( schema , ast , data ) ;
463
462
464
- expect ( result . data ) . to . deep . equal ( {
465
- sync : 'sync' ,
466
- syncError : null ,
467
- syncRawError : null ,
468
- syncReturnError : null ,
469
- syncReturnErrorList : [ 'sync0' , null , 'sync2' , null ] ,
470
- async : 'async' ,
471
- asyncReject : null ,
472
- asyncRawReject : null ,
473
- asyncEmptyReject : null ,
474
- asyncError : null ,
475
- asyncRawError : null ,
476
- asyncReturnError : null ,
477
- } ) ;
478
-
479
- expect ( result . errors && result . errors . map ( formatError ) ) . to . deep . equal ( [
480
- {
481
- message : 'Error getting syncError' ,
482
- locations : [ { line : 3 , column : 7 } ] ,
483
- path : [ 'syncError' ] ,
484
- } ,
485
- {
486
- message : 'Error getting syncRawError' ,
487
- locations : [ { line : 4 , column : 7 } ] ,
488
- path : [ 'syncRawError' ] ,
489
- } ,
490
- {
491
- message : 'Error getting syncReturnError' ,
492
- locations : [ { line : 5 , column : 7 } ] ,
493
- path : [ 'syncReturnError' ] ,
494
- } ,
495
- {
496
- message : 'Error getting syncReturnErrorList1' ,
497
- locations : [ { line : 6 , column : 7 } ] ,
498
- path : [ 'syncReturnErrorList' , 1 ] ,
499
- } ,
500
- {
501
- message : 'Error getting syncReturnErrorList3' ,
502
- locations : [ { line : 6 , column : 7 } ] ,
503
- path : [ 'syncReturnErrorList' , 3 ] ,
504
- } ,
505
- {
506
- message : 'Error getting asyncReject' ,
507
- locations : [ { line : 8 , column : 7 } ] ,
508
- path : [ 'asyncReject' ] ,
509
- } ,
510
- {
511
- message : 'Error getting asyncRawReject' ,
512
- locations : [ { line : 9 , column : 7 } ] ,
513
- path : [ 'asyncRawReject' ] ,
514
- } ,
515
- {
516
- message : 'An unknown error occurred.' ,
517
- locations : [ { line : 10 , column : 7 } ] ,
518
- path : [ 'asyncEmptyReject' ] ,
519
- } ,
520
- {
521
- message : 'Error getting asyncError' ,
522
- locations : [ { line : 11 , column : 7 } ] ,
523
- path : [ 'asyncError' ] ,
524
- } ,
525
- {
526
- message : 'Error getting asyncRawError' ,
527
- locations : [ { line : 12 , column : 7 } ] ,
528
- path : [ 'asyncRawError' ] ,
529
- } ,
530
- {
531
- message : 'Error getting asyncReturnError' ,
532
- locations : [ { line : 13 , column : 7 } ] ,
533
- path : [ 'asyncReturnError' ] ,
463
+ expect ( result ) . to . deep . equal ( {
464
+ data : {
465
+ sync : 'sync' ,
466
+ syncError : null ,
467
+ syncRawError : null ,
468
+ syncReturnError : null ,
469
+ syncReturnErrorList : [ 'sync0' , null , 'sync2' , null ] ,
470
+ async : 'async' ,
471
+ asyncReject : null ,
472
+ asyncRawReject : null ,
473
+ asyncEmptyReject : null ,
474
+ asyncError : null ,
475
+ asyncRawError : null ,
476
+ asyncReturnError : null ,
534
477
} ,
535
- ] ) ;
478
+ errors : [
479
+ {
480
+ message : 'Error getting syncError' ,
481
+ locations : [ { line : 3 , column : 7 } ] ,
482
+ path : [ 'syncError' ] ,
483
+ } ,
484
+ {
485
+ message : 'Error getting syncRawError' ,
486
+ locations : [ { line : 4 , column : 7 } ] ,
487
+ path : [ 'syncRawError' ] ,
488
+ } ,
489
+ {
490
+ message : 'Error getting syncReturnError' ,
491
+ locations : [ { line : 5 , column : 7 } ] ,
492
+ path : [ 'syncReturnError' ] ,
493
+ } ,
494
+ {
495
+ message : 'Error getting syncReturnErrorList1' ,
496
+ locations : [ { line : 6 , column : 7 } ] ,
497
+ path : [ 'syncReturnErrorList' , 1 ] ,
498
+ } ,
499
+ {
500
+ message : 'Error getting syncReturnErrorList3' ,
501
+ locations : [ { line : 6 , column : 7 } ] ,
502
+ path : [ 'syncReturnErrorList' , 3 ] ,
503
+ } ,
504
+ {
505
+ message : 'Error getting asyncReject' ,
506
+ locations : [ { line : 8 , column : 7 } ] ,
507
+ path : [ 'asyncReject' ] ,
508
+ } ,
509
+ {
510
+ message : 'Error getting asyncRawReject' ,
511
+ locations : [ { line : 9 , column : 7 } ] ,
512
+ path : [ 'asyncRawReject' ] ,
513
+ } ,
514
+ {
515
+ message : '' ,
516
+ locations : [ { line : 10 , column : 7 } ] ,
517
+ path : [ 'asyncEmptyReject' ] ,
518
+ } ,
519
+ {
520
+ message : 'Error getting asyncError' ,
521
+ locations : [ { line : 11 , column : 7 } ] ,
522
+ path : [ 'asyncError' ] ,
523
+ } ,
524
+ {
525
+ message : 'Error getting asyncRawError' ,
526
+ locations : [ { line : 12 , column : 7 } ] ,
527
+ path : [ 'asyncRawError' ] ,
528
+ } ,
529
+ {
530
+ message : 'Error getting asyncReturnError' ,
531
+ locations : [ { line : 13 , column : 7 } ] ,
532
+ path : [ 'asyncReturnError' ] ,
533
+ } ,
534
+ ] ,
535
+ } ) ;
536
536
} ) ;
537
537
538
538
it ( 'nulls error subtree for promise rejection #1071' , async ( ) => {
@@ -720,13 +720,7 @@ describe('Execute: Handles basic execution tasks', () => {
720
720
721
721
const result = await execute ( schema , ast , data ) ;
722
722
expect ( result ) . to . deep . equal ( {
723
- errors : [
724
- {
725
- message : 'Must provide an operation.' ,
726
- locations : undefined ,
727
- path : undefined ,
728
- } ,
729
- ] ,
723
+ errors : [ { message : 'Must provide an operation.' } ] ,
730
724
} ) ;
731
725
} ) ;
732
726
@@ -748,10 +742,7 @@ describe('Execute: Handles basic execution tasks', () => {
748
742
errors : [
749
743
{
750
744
message :
751
- 'Must provide operation name if query contains ' +
752
- 'multiple operations.' ,
753
- locations : undefined ,
754
- path : undefined ,
745
+ 'Must provide operation name if query contains multiple operations.' ,
755
746
} ,
756
747
] ,
757
748
} ) ;
@@ -775,13 +766,7 @@ describe('Execute: Handles basic execution tasks', () => {
775
766
operationName : 'UnknownExample' ,
776
767
} ) ;
777
768
expect ( result ) . to . deep . equal ( {
778
- errors : [
779
- {
780
- message : 'Unknown operation named "UnknownExample".' ,
781
- locations : undefined ,
782
- path : undefined ,
783
- } ,
784
- ] ,
769
+ errors : [ { message : 'Unknown operation named "UnknownExample".' } ] ,
785
770
} ) ;
786
771
} ) ;
787
772
@@ -1046,17 +1031,19 @@ describe('Execute: Handles basic execution tasks', () => {
1046
1031
} ;
1047
1032
const result = await execute ( schema , query , value ) ;
1048
1033
1049
- expect ( result . data ) . to . deep . equal ( {
1050
- specials : [ { value : 'foo' } , null ] ,
1051
- } ) ;
1052
- expect ( result . errors ) . to . have . lengthOf ( 1 ) ;
1053
- expect ( result . errors ) . to . containSubset ( [
1054
- {
1055
- message :
1056
- 'Expected value of type "SpecialType" but got: [object Object].' ,
1057
- locations : [ { line : 1 , column : 3 } ] ,
1034
+ expect ( result ) . to . deep . equal ( {
1035
+ data : {
1036
+ specials : [ { value : 'foo' } , null ] ,
1058
1037
} ,
1059
- ] ) ;
1038
+ errors : [
1039
+ {
1040
+ message :
1041
+ 'Expected value of type "SpecialType" but got: [object Object].' ,
1042
+ locations : [ { line : 1 , column : 3 } ] ,
1043
+ path : [ 'specials' , 1 ] ,
1044
+ } ,
1045
+ ] ,
1046
+ } ) ;
1060
1047
} ) ;
1061
1048
1062
1049
it ( 'executes ignoring invalid non-executable definitions' , async ( ) => {
0 commit comments