Skip to content

Commit 63f4a68

Browse files
committed
refactor(IncrementalGraph): remove unnecessary method
Replicates graphql/graphql-js@28e079a
1 parent 645f154 commit 63f4a68

File tree

1 file changed

+14
-25
lines changed

1 file changed

+14
-25
lines changed

src/graphql/execution/incremental_graph.py

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,26 @@ async def enqueue_stream(
105105

106106
def get_new_pending(self) -> list[SubsequentResultRecord]:
107107
"""Get new pending subsequent result records."""
108-
maybe_empty_new_pending = self._new_pending
109-
pending = self._pending
110-
add_non_empty_new_pending = self._add_non_empty_new_pending
108+
_pending, _new_pending = self._pending, self._new_pending
111109
new_pending: list[SubsequentResultRecord] = []
112-
append_new_pending = new_pending.append
113-
for node in maybe_empty_new_pending:
110+
add_result = new_pending.append
111+
# avoid iterating over a changing dict
112+
iterate = list(_new_pending)
113+
add_iteration = iterate.append
114+
while iterate:
115+
node = iterate.pop(0)
114116
if is_deferred_fragment_record(node):
115117
if node.expected_reconcilable_results:
116-
pending[node] = None
117-
append_new_pending(node)
118+
_pending[node] = None
119+
add_result(node)
118120
continue
119121
for child in node.children:
120-
add_non_empty_new_pending(child, new_pending)
122+
_new_pending[child] = None
123+
add_iteration(child)
121124
else:
122-
pending[node] = None
123-
append_new_pending(node)
124-
self._new_pending.clear()
125+
_pending[node] = None
126+
add_result(node)
127+
_new_pending.clear()
125128
return new_pending
126129

127130
async def completed_incremental_data(
@@ -186,20 +189,6 @@ def _add_deferred_fragment_record(
186189
parent.children[deferred_fragment_record] = None
187190
self._add_deferred_fragment_record(parent)
188191

189-
def _add_non_empty_new_pending(
190-
self,
191-
deferred_fragment_record: DeferredFragmentRecord,
192-
new_pending: list[SubsequentResultRecord],
193-
) -> None:
194-
"""Add non-empty new pending deferred fragment record."""
195-
if deferred_fragment_record.expected_reconcilable_results:
196-
self._pending[deferred_fragment_record] = None
197-
new_pending.append(deferred_fragment_record)
198-
return
199-
add = self._add_non_empty_new_pending # pragma: no cover
200-
for child in deferred_fragment_record.children: # pragma: no cover
201-
add(child, new_pending)
202-
203192
def _enqueue_completed_deferred_grouped_field_set(
204193
self, result: DeferredGroupedFieldSetResult
205194
) -> None:

0 commit comments

Comments
 (0)