@@ -251,21 +251,7 @@ def complete_value(self, ctx, return_type, field_asts, info, result):
251
251
252
252
# If field type is List, complete each item in the list with the inner type
253
253
if isinstance (return_type , GraphQLList ):
254
- assert isinstance (result , collections .Iterable ), \
255
- ('User Error: expected iterable, but did not find one' +
256
- 'for field {}.{}' ).format (info .parent_type , info .field_name )
257
-
258
- item_type = return_type .of_type
259
- completed_results = []
260
- contains_deferred = False
261
- for item in result :
262
- completed_item = self .complete_value_catching_error (ctx , item_type , field_asts , info , item )
263
- if not contains_deferred and isinstance (completed_item , Deferred ):
264
- contains_deferred = True
265
-
266
- completed_results .append (completed_item )
267
-
268
- return DeferredList (completed_results ) if contains_deferred else completed_results
254
+ return self .complete_list_value (ctx , return_type , field_asts , info , result )
269
255
270
256
# If field type is Scalar or Enum, serialize to a valid value, returning null if coercion is not possible.
271
257
if isinstance (return_type , (GraphQLScalarType , GraphQLEnumType )):
@@ -312,6 +298,26 @@ def complete_value(self, ctx, return_type, field_asts, info, result):
312
298
313
299
return self ._execute_fields (ctx , runtime_type , result , subfield_asts )
314
300
301
+ def complete_list_value (self , ctx , return_type , field_asts , info , result ):
302
+ """
303
+ Complete a list value by completing each item in the list with the inner type
304
+ """
305
+ assert isinstance (result , collections .Iterable ), \
306
+ ('User Error: expected iterable, but did not find one' +
307
+ 'for field {}.{}' ).format (info .parent_type , info .field_name )
308
+
309
+ item_type = return_type .of_type
310
+ completed_results = []
311
+ contains_deferred = False
312
+ for item in result :
313
+ completed_item = self .complete_value_catching_error (ctx , item_type , field_asts , info , item )
314
+ if not contains_deferred and isinstance (completed_item , Deferred ):
315
+ contains_deferred = True
316
+
317
+ completed_results .append (completed_item )
318
+
319
+ return DeferredList (completed_results ) if contains_deferred else completed_results
320
+
315
321
def resolve_or_error (self , resolve_fn , source , args , info ):
316
322
curried_resolve_fn = functools .partial (resolve_fn , source , args , info )
317
323
0 commit comments