Skip to content

Commit 39b5fb3

Browse files
committed
[Validation] Unwrap recursion for collecting fragment spreads
Related GraphQL-js commit: graphql/graphql-js@4e610b7
1 parent 891d4a6 commit 39b5fb3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

graphql/core/validation/context.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ def get_fragment_spreads(self, node):
100100
spreads = self._fragment_spreads.get(node)
101101
if not spreads:
102102
spreads = []
103-
self.gather_spreads(spreads, node.selection_set)
103+
sets_to_visit = [node.selection_set]
104+
while sets_to_visit:
105+
_set = sets_to_visit.pop()
106+
for selection in _set.selections:
107+
if isinstance(selection, FragmentSpread):
108+
spreads.append(selection)
109+
elif selection.selection_set:
110+
sets_to_visit.append(selection.selection_set)
111+
104112
self._fragment_spreads[node] = spreads
105113
return spreads
106114

@@ -133,11 +141,3 @@ def get_directive(self):
133141

134142
def get_argument(self):
135143
return self._type_info.get_argument()
136-
137-
@classmethod
138-
def gather_spreads(cls, spreads, node):
139-
for selection in node.selections:
140-
if isinstance(selection, FragmentSpread):
141-
spreads.append(selection)
142-
elif selection.selection_set:
143-
cls.gather_spreads(spreads, selection.selection_set)

0 commit comments

Comments
 (0)