Skip to content

Commit c4c4142

Browse files
committed
refactor: introduce complete_iterable_value
Replicates graphql/graphql-js@d811c97
1 parent 010987b commit c4c4142

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/graphql/execution/execute.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,9 +1057,30 @@ def complete_list_value(
10571057
)
10581058
raise GraphQLError(msg)
10591059

1060-
# This is specified as a simple map, however we're optimizing the path where
1061-
# the list contains no coroutine objects by avoiding creating another coroutine
1062-
# object.
1060+
return self.complete_iterable_value(
1061+
item_type,
1062+
field_group,
1063+
info,
1064+
path,
1065+
result,
1066+
incremental_context,
1067+
defer_map,
1068+
)
1069+
1070+
def complete_iterable_value(
1071+
self,
1072+
item_type: GraphQLOutputType,
1073+
field_group: FieldGroup,
1074+
info: GraphQLResolveInfo,
1075+
path: Path,
1076+
items: Iterable[Any],
1077+
incremental_context: IncrementalContext | None,
1078+
defer_map: RefMap[DeferUsage, DeferredFragmentRecord] | None,
1079+
) -> AwaitableOrValue[GraphQLWrappedResult[list[Any]]]:
1080+
"""Complete an iterable value."""
1081+
# This is specified as a simple map, however we're optimizing the path
1082+
# where the list contains no awaitable routine objects by avoiding creating
1083+
# another awaitable object.
10631084
is_awaitable = self.is_awaitable
10641085
complete_list_item_value = self.complete_list_item_value
10651086
complete_awaitable_list_item_value = self.complete_awaitable_list_item_value
@@ -1070,7 +1091,7 @@ def complete_list_value(
10701091
awaitable_indices: list[int] = []
10711092
append_awaitable = awaitable_indices.append
10721093
stream_usage = self.get_stream_usage(field_group, path)
1073-
iterator = iter(result)
1094+
iterator = iter(items)
10741095
index = 0
10751096
while True:
10761097
try:

0 commit comments

Comments
 (0)