@@ -87,16 +87,23 @@ async def on_start(self, connection_context, op_id, params):
8787 if hasattr (execution_result , "__aiter__" ):
8888 iterator = await execution_result .__aiter__ ()
8989 connection_context .register_operation (op_id , iterator )
90- async for single_result in iterator :
91- if not connection_context .has_operation (op_id ):
92- break
90+ try :
91+ async for single_result in iterator :
92+ if not connection_context .has_operation (op_id ):
93+ break
94+ await self .send_execution_result (
95+ connection_context , op_id , single_result
96+ )
97+ except Exception as e :
98+ await self .send_error (connection_context , op_id , e )
99+ connection_context .remove_operation (op_id )
100+ else :
101+ try :
93102 await self .send_execution_result (
94- connection_context , op_id , single_result
103+ connection_context , op_id , execution_result
95104 )
96- else :
97- await self .send_execution_result (
98- connection_context , op_id , execution_result
99- )
105+ except Exception as e :
106+ await self .send_error (connection_context , op_id , e )
100107 await self .send_message (connection_context , op_id , GQL_COMPLETE )
101108 await self .on_operation_complete (connection_context , op_id )
102109
0 commit comments