Skip to content

Commit 2d5433b

Browse files
committed
fix shadow SIL issue
1 parent ff61df6 commit 2d5433b

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

Sources/GraphQL/Validation/Rules/KnownDirectivesRule.swift

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,32 @@ func KnownDirectivesRule(context: ValidationContext) -> Visitor {
2525

2626
return Visitor(
2727
enter: { node, _, _, _, ancestors in
28-
if let node = node as? Directive {
29-
let name = node.name.value
30-
let locations = locationsMap[name]
28+
guard let node = node as? Directive else { return .continue }
3129

32-
guard let locations = locations else {
33-
context.report(
34-
error: GraphQLError(
35-
message: "Unknown directive \"@\(name)\".",
36-
nodes: [node]
37-
)
38-
)
39-
return .continue
40-
}
30+
let name = node.name.value
4131

42-
let candidateLocation = getDirectiveLocationForASTPath(ancestors)
43-
if
44-
let candidateLocation = candidateLocation,
45-
!locations.contains(candidateLocation.rawValue)
46-
{
47-
context.report(
48-
error: GraphQLError(
49-
message: "Directive \"@\(name)\" may not be used on \(candidateLocation.rawValue).",
50-
nodes: [node]
51-
)
32+
guard let locations = locationsMap[name] else {
33+
context.report(
34+
error: GraphQLError(
35+
message: "Unknown directive \"@\(name)\".",
36+
nodes: [node]
5237
)
53-
}
38+
)
39+
return .continue
5440
}
41+
42+
guard
43+
let candidateLocation = getDirectiveLocationForASTPath(ancestors),
44+
!locations.contains(candidateLocation.rawValue)
45+
else { return .continue }
46+
47+
context.report(
48+
error: GraphQLError(
49+
message: "Directive \"@\(name)\" may not be used on \(candidateLocation.rawValue).",
50+
nodes: [node]
51+
)
52+
)
53+
5554
return .continue
5655
}
5756
)

0 commit comments

Comments
 (0)