@@ -142,6 +142,7 @@ async def on_start(self, connection_context, op_id, params):
142142
143143 execution_result = self .execute (params )
144144
145+ connection_context .register_operation (op_id , execution_result )
145146 if is_awaitable (execution_result ):
146147 execution_result = await execution_result
147148
@@ -157,7 +158,6 @@ async def on_start(self, connection_context, op_id, params):
157158 )
158159 except Exception as e :
159160 await self .send_error (connection_context , op_id , e )
160- connection_context .remove_operation (op_id )
161161 else :
162162 try :
163163 await self .send_execution_result (
@@ -166,8 +166,16 @@ async def on_start(self, connection_context, op_id, params):
166166 except Exception as e :
167167 await self .send_error (connection_context , op_id , e )
168168 await self .send_message (connection_context , op_id , GQL_COMPLETE )
169+ connection_context .remove_operation (op_id )
169170 await self .on_operation_complete (connection_context , op_id )
170171
172+ async def send_message (
173+ self , connection_context , op_id = None , op_type = None , payload = None
174+ ):
175+ if op_id is None or connection_context .has_operation (op_id ):
176+ message = self .build_message (op_id , op_type , payload )
177+ return await connection_context .send (message )
178+
171179 async def on_operation_complete (self , connection_context , op_id ):
172180 pass
173181
0 commit comments