Skip to content

Commit fcb48ba

Browse files
authored
Merge pull request #3995 from graphql-java/deterministic-source-location-backport-24
Deterministic source location backport 24
2 parents 1db8cf4 + e72fddc commit fcb48ba

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

.github/workflows/master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v4
19-
- uses: gradle/wrapper-validation-action@v3
19+
- uses: gradle/actions/wrapper-validation@v4
2020
- name: Set up JDK 11
2121
uses: actions/setup-java@v4
2222
with:

.github/workflows/pull_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- uses: actions/checkout@v4
24-
- uses: gradle/wrapper-validation-action@v3
24+
- uses: gradle/actions/wrapper-validation@v4
2525
- name: Set up JDK 11
2626
uses: actions/setup-java@v4
2727
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- uses: actions/checkout@v4
21-
- uses: gradle/wrapper-validation-action@v3
21+
- uses: gradle/actions/wrapper-validation@v4
2222
- name: Set up JDK 11
2323
uses: actions/setup-java@v4
2424
with:

src/main/java/graphql/GraphqlErrorHelper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ public static Object location(SourceLocation location) {
7373
if (line < 1 || column < 1) {
7474
return null;
7575
}
76-
return Map.of("line", line, "column", column);
76+
LinkedHashMap<String, Object> map = new LinkedHashMap<>(2);
77+
map.put("line", line);
78+
map.put("column", column);
79+
return map;
7780
}
7881

7982
static List<GraphQLError> fromSpecification(List<Map<String, Object>> specificationMaps) {

src/test/groovy/graphql/GraphqlErrorHelperTest.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package graphql
33
import graphql.language.SourceLocation
44
import graphql.validation.ValidationError
55
import graphql.validation.ValidationErrorType
6+
import spock.lang.RepeatUntilFailure
67
import spock.lang.Specification
78

89
class GraphqlErrorHelperTest extends Specification {
@@ -154,4 +155,15 @@ class GraphqlErrorHelperTest extends Specification {
154155
assert gErr.getExtensions() == null
155156
}
156157
}
158+
159+
@RepeatUntilFailure(maxAttempts = 1_000)
160+
def "can deterministically serialize SourceLocation"() {
161+
when:
162+
def specMap = GraphqlErrorHelper.toSpecification(new TestError())
163+
164+
then:
165+
def location = specMap["locations"][0] as Map<String, Object>
166+
def keys = location.keySet().toList()
167+
keys == ["line", "column"]
168+
}
157169
}

0 commit comments

Comments
 (0)