@@ -16,12 +16,21 @@ import {
16
16
17
17
18
18
function badValue ( argName , typeName , value , line , column , errors ) {
19
+ var realErrors ;
20
+ if ( ! errors ) {
21
+ realErrors = [
22
+ `Expected type "${ typeName } ", found ${ value } .`
23
+ ] ;
24
+ } else {
25
+ realErrors = errors ;
26
+ }
19
27
return {
20
- message : badValueMessage ( argName , typeName , value , errors ) ,
28
+ message : badValueMessage ( argName , typeName , value , realErrors ) ,
21
29
locations : [ { line, column } ] ,
22
30
} ;
23
31
}
24
32
33
+
25
34
describe ( 'Validate: Argument values of correct type' , ( ) => {
26
35
27
36
describe ( 'Valid values' , ( ) => {
@@ -484,7 +493,9 @@ describe('Validate: Argument values of correct type', () => {
484
493
}
485
494
}
486
495
` , [
487
- badValue ( 'stringListArg' , '[String]' , '["one", 2]' , 4 , 47 ) ,
496
+ badValue ( 'stringListArg' , '[String]' , '["one", 2]' , 4 , 47 , [
497
+ 'In element #1: Expected type "String", found 2.'
498
+ ] ) ,
488
499
] ) ;
489
500
} ) ;
490
501
@@ -496,7 +507,7 @@ describe('Validate: Argument values of correct type', () => {
496
507
}
497
508
}
498
509
` , [
499
- badValue ( 'stringListArg' , '[ String] ' , '1' , 4 , 47 ) ,
510
+ badValue ( 'stringListArg' , 'String' , '1' , 4 , 47 ) ,
500
511
] ) ;
501
512
} ) ;
502
513
@@ -618,8 +629,8 @@ describe('Validate: Argument values of correct type', () => {
618
629
}
619
630
}
620
631
` , [
621
- badValue ( 'req2' , 'Int! ' , '"two"' , 4 , 32 ) ,
622
- badValue ( 'req1' , 'Int! ' , '"one"' , 4 , 45 ) ,
632
+ badValue ( 'req2' , 'Int' , '"two"' , 4 , 32 ) ,
633
+ badValue ( 'req1' , 'Int' , '"one"' , 4 , 45 ) ,
623
634
] ) ;
624
635
} ) ;
625
636
@@ -631,7 +642,7 @@ describe('Validate: Argument values of correct type', () => {
631
642
}
632
643
}
633
644
` , [
634
- badValue ( 'req1' , 'Int! ' , '"one"' , 4 , 32 ) ,
645
+ badValue ( 'req1' , 'Int' , '"one"' , 4 , 32 ) ,
635
646
] ) ;
636
647
} ) ;
637
648
@@ -726,7 +737,7 @@ describe('Validate: Argument values of correct type', () => {
726
737
}
727
738
` , [
728
739
badValue ( 'complexArg' , 'ComplexInput' , '{intField: 4}' , 4 , 41 , [
729
- 'In field requiredField: Expected non-null value .'
740
+ 'In field " requiredField" : Expected "Boolean!", found null .'
730
741
] ) ,
731
742
] ) ;
732
743
} ) ;
@@ -747,7 +758,9 @@ describe('Validate: Argument values of correct type', () => {
747
758
'ComplexInput' ,
748
759
'{stringListField: ["one", 2], requiredField: true}' ,
749
760
4 ,
750
- 41
761
+ 41 ,
762
+ [ 'In field "stringListField": In element #1: ' +
763
+ 'Expected type "String", found 2.' ]
751
764
) ,
752
765
] ) ;
753
766
} ) ;
@@ -769,7 +782,7 @@ describe('Validate: Argument values of correct type', () => {
769
782
'{requiredField: true, unknownField: "value"}' ,
770
783
4 ,
771
784
41 ,
772
- [ 'Unknown field unknownField.' ]
785
+ [ 'Unknown field " unknownField" .' ]
773
786
) ,
774
787
] ) ;
775
788
} ) ;
@@ -799,8 +812,8 @@ describe('Validate: Argument values of correct type', () => {
799
812
}
800
813
}
801
814
` , [
802
- badValue ( 'if' , 'Boolean! ' , '"yes"' , 3 , 28 ) ,
803
- badValue ( 'if' , 'Boolean! ' , 'ENUM' , 4 , 28 ) ,
815
+ badValue ( 'if' , 'Boolean' , '"yes"' , 3 , 28 ) ,
816
+ badValue ( 'if' , 'Boolean' , 'ENUM' , 4 , 28 ) ,
804
817
] ) ;
805
818
} ) ;
806
819
0 commit comments