Filter out negative line and column error locations in toSpecification#3753
Filter out negative line and column error locations in toSpecification#3753
Conversation
|
|
||
| List<SourceLocation> mkLocations() { | ||
| return [mkLocation(666, 999), mkLocation(333, 0)] | ||
| return [mkLocation(666, 999), mkLocation(333, 1)] |
There was a problem hiding this comment.
Fix old tests to be compliant
| if (line < 1 || column < 1) { | ||
| return null; | ||
| } | ||
| return Map.of("line", line, "column", column); |
There was a problem hiding this comment.
Tiny change, this becomes an immutable map
Test Results 304 files ±0 304 suites ±0 45s ⏱️ +5s Results for commit 69569de. ± Comparison against base commit f83ba25. This pull request removes 129 and adds 108 tests. Note that renamed tests count towards both. |
| .build() | | ||
| [ | ||
| locations: [[line: 666, column: 999], [line: 333, column: 0]], | ||
| locations: [[line: 666, column: 999], [line: 333, column: 1]], |
There was a problem hiding this comment.
Why do these numbers chance - what caused that?
There was a problem hiding this comment.
In the past, our tests had "0" being used as a valid column location. This PR bans anything less than 1 for line and column number, which made these old tests fail. So I adjusted these old tests to use a valid location number
Then added a new test with invalid numbers to check the new filtering behaviour
There was a problem hiding this comment.
The source locations for these old tests are generated by a method lower down in this file
List<SourceLocation> mkLocations()
Fixes #3661
Internally graphql-java represents an "empty"
SourceLocationas line -1 and column -1.graphql-java/src/main/java/graphql/parser/ExtendedBailStrategy.java
Line 72 in ee32161
However in the issue raised it turns out the specification requires these numbers to be positive integers, starting at 1. https://spec.graphql.org/draft/#sel-GAPHRPFCCaCGX5zM
This PR updates the toSpecification method to filter out error locations that do not have both a positive line and column number. This only changes
toSpecificationand not any internal representation of SourceLocation.This could be considered a breaking change, however it's necessary to bring behaviour in line with the spec.