Skip to content

Commit

Permalink
Merge pull request #141 from NoDevOrg/swift-5.4
Browse files Browse the repository at this point in the history
Fix issue with shadow variables in Swift 5.4
  • Loading branch information
NeedleInAJayStack authored Mar 21, 2024
2 parents 63c74fa + 2d5433b commit 3cf2dbc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
45 changes: 22 additions & 23 deletions Sources/GraphQL/Validation/Rules/KnownDirectivesRule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
Expand Down

0 comments on commit 3cf2dbc

Please sign in to comment.