File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -267,6 +267,7 @@ def subscribe_fields(
267267 parent_type , # type: GraphQLObjectType
268268 source_value , # type: Any
269269 fields , # type: DefaultOrderedDict
270+ only_first_field = True , # type: bool
270271):
271272 # type: (...) -> Observable
272273 subscriber_exe_context = SubscriberExecutionContext (exe_context )
@@ -290,7 +291,7 @@ def catch_error(error):
290291 observables = [] # type: List[Observable]
291292
292293 # TODO: Make sure this works with multiple fields (currently untested)
293- # assert len(fields) == 1, "Can only subscribe one element at a time."
294+ # so we can remove the "only_first_field" argument.
294295
295296 for response_name , field_asts in fields .items ():
296297 result = subscribe_field (
@@ -306,9 +307,11 @@ def catch_error(error):
306307 observable = result .catch_exception (catch_error ).map (
307308 lambda data : map_result ({response_name : data })
308309 )
310+ if only_first_field :
311+ return observable
309312 observables .append (observable )
310313
311- return observables [ 0 ] if len ( observables ) == 1 else Observable .merge (observables )
314+ return Observable .merge (observables )
312315
313316
314317def resolve_field (
You can’t perform that action at this time.
0 commit comments