File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,9 @@ public static Object locations(List<SourceLocation> locations) {
6565 * @return a value for source location of the error
6666 */
6767 public static Object location (SourceLocation location ) {
68+ if (location == null ) {
69+ return null ;
70+ }
6871 int line = location .getLine ();
6972 int column = location .getColumn ();
7073 if (line < 1 || column < 1 ) {
Original file line number Diff line number Diff line change @@ -94,6 +94,26 @@ class GraphQLErrorTest extends Specification {
9494 error. toSpecification() == expectedMap
9595 }
9696
97+ def " toSpecification filters out null error locations" () {
98+ given :
99+ def error = ValidationError . newValidationError()
100+ .validationErrorType(ValidationErrorType.UnknownType )
101+ .sourceLocations([null , mkLocation(333 , 1 )])
102+ .description(" Test ValidationError" )
103+ .build()
104+
105+ def expectedMap = [
106+ locations : [
107+ [line : 333 , column : 1 ]
108+ ],
109+ message : " Test ValidationError" ,
110+ extensions : [classification :" ValidationError" ]
111+ ]
112+
113+ expect :
114+ error. toSpecification() == expectedMap
115+ }
116+
97117 class CustomException extends RuntimeException implements GraphQLError {
98118 private LinkedHashMap<String , String > map
99119
You can’t perform that action at this time.
0 commit comments