-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Filter out negative line and column error locations in toSpecification #3753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -110,7 +132,7 @@ class GraphQLErrorTest extends Specification { | |||
} | |||
|
|||
List<SourceLocation> mkLocations() { | |||
return [mkLocation(666, 999), mkLocation(333, 0)] | |||
return [mkLocation(666, 999), mkLocation(333, 1)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix old tests to be compliant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see
if (line < 1 || column < 1) { | ||
return null; | ||
} | ||
return Map.of("line", line, "column", column); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
@@ -31,7 +31,7 @@ class GraphQLErrorTest extends Specification { | |||
.description("Test ValidationError") | |||
.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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do these numbers chance - what caused that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"
SourceLocation
as 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
toSpecification
and 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.