@@ -31,7 +31,7 @@ class GraphQLErrorTest extends Specification {
31
31
.description(" Test ValidationError" )
32
32
.build() |
33
33
[
34
- locations : [[line : 666 , column : 999 ], [line : 333 , column : 0 ]],
34
+ locations : [[line : 666 , column : 999 ], [line : 333 , column : 1 ]],
35
35
message : " Test ValidationError" ,
36
36
extensions :[classification :" ValidationError" ],
37
37
]
@@ -44,7 +44,7 @@ class GraphQLErrorTest extends Specification {
44
44
45
45
new InvalidSyntaxError (mkLocations(), " Not good syntax m'kay" ) |
46
46
[
47
- locations : [[line : 666 , column : 999 ], [line : 333 , column : 0 ]],
47
+ locations : [[line : 666 , column : 999 ], [line : 333 , column : 1 ]],
48
48
message : " Not good syntax m'kay" ,
49
49
extensions :[classification :" InvalidSyntax" ],
50
50
]
@@ -72,6 +72,28 @@ class GraphQLErrorTest extends Specification {
72
72
73
73
}
74
74
75
+ def " toSpecification filters out error locations with line and column not starting at 1, as required in spec" () {
76
+ // See specification wording: https://spec.graphql.org/draft/#sec-Errors.Error-Result-Format
77
+
78
+ given :
79
+ def error = ValidationError . newValidationError()
80
+ .validationErrorType(ValidationErrorType.UnknownType )
81
+ .sourceLocations([mkLocation(-1 , -1 ), mkLocation(333 , 1 )])
82
+ .description(" Test ValidationError" )
83
+ .build()
84
+
85
+ def expectedMap = [
86
+ locations : [
87
+ [line : 333 , column : 1 ]
88
+ ],
89
+ message : " Test ValidationError" ,
90
+ extensions : [classification :" ValidationError" ]
91
+ ]
92
+
93
+ expect :
94
+ error. toSpecification() == expectedMap
95
+ }
96
+
75
97
class CustomException extends RuntimeException implements GraphQLError {
76
98
private LinkedHashMap<String , String > map
77
99
@@ -110,7 +132,7 @@ class GraphQLErrorTest extends Specification {
110
132
}
111
133
112
134
List<SourceLocation > mkLocations () {
113
- return [mkLocation(666 , 999 ), mkLocation(333 , 0 )]
135
+ return [mkLocation(666 , 999 ), mkLocation(333 , 1 )]
114
136
}
115
137
116
138
SourceLocation mkLocation (int line , int column ) {
0 commit comments