From 9ba39f3cf5b6f74c3c0043cedcc9624755bcc287 Mon Sep 17 00:00:00 2001 From: James Bellenger Date: Sat, 24 May 2025 05:26:01 -0700 Subject: [PATCH 1/3] deterministically serialize SourceLocation (cherry picked from commit 71444d842a81f66d3fc1fa75f54bf5767608663b) --- src/main/java/graphql/GraphqlErrorHelper.java | 5 ++++- .../groovy/graphql/GraphqlErrorHelperTest.groovy | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/graphql/GraphqlErrorHelper.java b/src/main/java/graphql/GraphqlErrorHelper.java index 391b223d9..901c25b5a 100644 --- a/src/main/java/graphql/GraphqlErrorHelper.java +++ b/src/main/java/graphql/GraphqlErrorHelper.java @@ -73,7 +73,10 @@ public static Object location(SourceLocation location) { if (line < 1 || column < 1) { return null; } - return Map.of("line", line, "column", column); + LinkedHashMap map = new LinkedHashMap<>(2); + map.put("line", line); + map.put("column", column); + return map; } static List fromSpecification(List> specificationMaps) { diff --git a/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy b/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy index 018c9f157..5b5ce391c 100644 --- a/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy +++ b/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy @@ -3,6 +3,7 @@ package graphql import graphql.language.SourceLocation import graphql.validation.ValidationError import graphql.validation.ValidationErrorType +import spock.lang.RepeatUntilFailure import spock.lang.Specification class GraphqlErrorHelperTest extends Specification { @@ -120,7 +121,7 @@ class GraphqlErrorHelperTest extends Specification { when: rawError = [message: "m"] - graphQLError = GraphQLError.fromSpecification(rawError) // just so we reference the public method + graphQLError = GraphQLError.fromSpecification(rawError) // vso we reference the public method then: graphQLError.getMessage() == "m" graphQLError.getErrorType() == ErrorType.DataFetchingException // default from error builder @@ -154,4 +155,15 @@ class GraphqlErrorHelperTest extends Specification { assert gErr.getExtensions() == null } } + + @RepeatUntilFailure(maxAttempts = 1_000) + def "can deterministically serialize SourceLocation"() { + when: + def specMap = GraphqlErrorHelper.toSpecification(new TestError()) + + then: + def location = specMap["locations"][0] as Map + def keys = location.keySet().toList() + keys == ["line", "column"] + } } From a66c594ee558def14a6e36a59753ae024b2b0bcd Mon Sep 17 00:00:00 2001 From: James Bellenger Date: Sat, 24 May 2025 05:26:47 -0700 Subject: [PATCH 2/3] tidy (cherry picked from commit baf1125302cac191a10762c49e11f7f15e7a933e) --- src/test/groovy/graphql/GraphqlErrorHelperTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy b/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy index 5b5ce391c..0736b1671 100644 --- a/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy +++ b/src/test/groovy/graphql/GraphqlErrorHelperTest.groovy @@ -121,7 +121,7 @@ class GraphqlErrorHelperTest extends Specification { when: rawError = [message: "m"] - graphQLError = GraphQLError.fromSpecification(rawError) // vso we reference the public method + graphQLError = GraphQLError.fromSpecification(rawError) // just so we reference the public method then: graphQLError.getMessage() == "m" graphQLError.getErrorType() == ErrorType.DataFetchingException // default from error builder From e72fddc4f84f675cb82970668a0be7e83017a8db Mon Sep 17 00:00:00 2001 From: Andreas Marek Date: Fri, 23 May 2025 07:15:10 +1000 Subject: [PATCH 3/3] update gradle wrapper validation (cherry picked from commit fe61c2dfc89f6fd0d5fe9e4b67fe3281b7dcdaae) --- .github/workflows/master.yml | 2 +- .github/workflows/pull_request.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 74651d884..ffcf66197 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -16,7 +16,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v3 + - uses: gradle/actions/wrapper-validation@v4 - name: Set up JDK 11 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 98a5a3e35..61f24f3d2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v3 + - uses: gradle/actions/wrapper-validation@v4 - name: Set up JDK 11 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 21b31d32e..2d630314c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v3 + - uses: gradle/actions/wrapper-validation@v4 - name: Set up JDK 11 uses: actions/setup-java@v4 with: