From ff61df6bf6dce05b208a948422ec16b771809659 Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Tue, 19 Mar 2024 17:08:43 -0700 Subject: [PATCH 1/2] add swift 5.4 as a build target --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 491d2aaa..da53fb30 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,7 +76,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - swift: ["5.5", "5.6"] + swift: ["5.4", "5.5", "5.6"] steps: - uses: swift-actions/setup-swift@v1 with: From 2d5433b4896bec75000bdb5b4866554c64a622a6 Mon Sep 17 00:00:00 2001 From: Sami Suteria Date: Tue, 19 Mar 2024 17:09:01 -0700 Subject: [PATCH 2/2] fix shadow SIL issue --- .../Rules/KnownDirectivesRule.swift | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/Sources/GraphQL/Validation/Rules/KnownDirectivesRule.swift b/Sources/GraphQL/Validation/Rules/KnownDirectivesRule.swift index 5d893520..18be3c0a 100644 --- a/Sources/GraphQL/Validation/Rules/KnownDirectivesRule.swift +++ b/Sources/GraphQL/Validation/Rules/KnownDirectivesRule.swift @@ -25,33 +25,32 @@ func KnownDirectivesRule(context: ValidationContext) -> Visitor { return Visitor( enter: { node, _, _, _, ancestors in - if let node = node as? Directive { - let name = node.name.value - let locations = locationsMap[name] + guard let node = node as? Directive else { return .continue } - guard let locations = locations else { - context.report( - error: GraphQLError( - message: "Unknown directive \"@\(name)\".", - nodes: [node] - ) - ) - return .continue - } + let name = node.name.value - let candidateLocation = getDirectiveLocationForASTPath(ancestors) - if - let candidateLocation = candidateLocation, - !locations.contains(candidateLocation.rawValue) - { - context.report( - error: GraphQLError( - message: "Directive \"@\(name)\" may not be used on \(candidateLocation.rawValue).", - nodes: [node] - ) + guard let locations = locationsMap[name] else { + context.report( + error: GraphQLError( + message: "Unknown directive \"@\(name)\".", + nodes: [node] ) - } + ) + return .continue } + + guard + let candidateLocation = getDirectiveLocationForASTPath(ancestors), + !locations.contains(candidateLocation.rawValue) + else { return .continue } + + context.report( + error: GraphQLError( + message: "Directive \"@\(name)\" may not be used on \(candidateLocation.rawValue).", + nodes: [node] + ) + ) + return .continue } )