Skip to content

Commit dc14896

Browse files
fix: Fixes unpredictable fragment path matching
1 parent c118fc3 commit dc14896

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Sources/GraphQL/Validation/Validate.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,11 @@ public final class ValidationContext {
165165
}
166166

167167
public func getFragmentSpreads(node: SelectionSet) -> [FragmentSpread] {
168-
if let spreads = fragmentSpreads[node] {
169-
return spreads
170-
}
168+
// Uncommenting this creates unpredictably wrong fragment path matching.
169+
// Failures can be seen in NoFragmentCyclesRuleTests.testNoSpreadingItselfDeeplyTwoPaths
170+
// if let spreads = fragmentSpreads[node] {
171+
// return spreads
172+
// }
171173

172174
var spreads = [FragmentSpread]()
173175
var setsToVisit: [SelectionSet] = [node]
@@ -176,19 +178,18 @@ public final class ValidationContext {
176178
for selection in set.selections {
177179
if let selection = selection as? FragmentSpread {
178180
spreads.append(selection)
179-
}
180-
181-
if let selection = selection as? InlineFragment {
181+
} else if let selection = selection as? InlineFragment {
182182
setsToVisit.append(selection.selectionSet)
183-
}
184-
185-
if let selection = selection as? Field, let selectionSet = selection.selectionSet {
183+
} else if
184+
let selection = selection as? Field,
185+
let selectionSet = selection.selectionSet
186+
{
186187
setsToVisit.append(selectionSet)
187188
}
188189
}
189190
}
190191

191-
fragmentSpreads[node] = spreads
192+
// fragmentSpreads[node] = spreads
192193
return spreads
193194
}
194195

0 commit comments

Comments
 (0)