11use std:: sync:: Arc ;
22
33use hive_router_plan_executor:: {
4- execution:: {
5- client_request_details:: { ClientRequestDetails , JwtRequestDetails , OperationDetails } ,
6- plan:: PlanExecutionOutput ,
4+ execution:: client_request_details:: {
5+ ClientRequestDetails , JwtRequestDetails , OperationDetails ,
76 } ,
7+ executors:: http:: HttpResponse ,
88 hooks:: {
9- on_graphql_params:: { OnGraphQLParamsEndPayload , OnGraphQLParamsStartPayload } ,
9+ on_graphql_params:: { OnGraphQLParamsEndHookPayload , OnGraphQLParamsStartHookPayload } ,
1010 on_supergraph_load:: SupergraphData ,
1111 } ,
1212 plugin_context:: { PluginContext , PluginRequestState , RouterHttpRequest } ,
13- plugin_trait:: ControlFlowResult ,
13+ plugin_trait:: { EndControlFlow , StartControlFlow } ,
1414} ;
1515use hive_router_query_planner:: {
1616 state:: supergraph_state:: OperationKind , utils:: cancellation:: CancellationToken ,
@@ -126,7 +126,7 @@ pub async fn graphql_request_handler(
126126 )
127127 . await ?;
128128 let response_status = response. status ;
129- let response_bytes = Bytes :: from ( response. body ) ;
129+ let response_bytes = response. body ;
130130 let response_headers = response. headers ;
131131
132132 let mut response_builder = web:: HttpResponse :: Ok ( ) ;
@@ -139,7 +139,7 @@ pub async fn graphql_request_handler(
139139 Ok ( response_builder
140140 . header ( http:: header:: CONTENT_TYPE , response_content_type)
141141 . status ( response_status)
142- . body ( response_bytes) )
142+ . body ( response_bytes. to_vec ( ) ) )
143143}
144144
145145#[ inline]
@@ -152,7 +152,7 @@ pub async fn execute_pipeline(
152152 schema_state : & SchemaState ,
153153 jwt_context : Option < JwtRequestContext > ,
154154 plugin_req_state : Option < PluginRequestState < ' _ > > ,
155- ) -> Result < PlanExecutionOutput , PipelineErrorVariant > {
155+ ) -> Result < HttpResponse , PipelineErrorVariant > {
156156 perform_csrf_prevention ( req, & shared_state. router_config . csrf ) ?;
157157
158158 /* Handle on_deserialize hook in the plugins - START */
@@ -161,8 +161,8 @@ pub async fn execute_pipeline(
161161 let mut graphql_params = None ;
162162 let mut body = body;
163163 if let Some ( plugin_req_state) = plugin_req_state. as_ref ( ) {
164- let mut deserialization_payload: OnGraphQLParamsStartPayload =
165- OnGraphQLParamsStartPayload {
164+ let mut deserialization_payload: OnGraphQLParamsStartHookPayload =
165+ OnGraphQLParamsStartHookPayload {
166166 router_http_request : & plugin_req_state. router_http_request ,
167167 context : & plugin_req_state. context ,
168168 body,
@@ -172,11 +172,11 @@ pub async fn execute_pipeline(
172172 let result = plugin. on_graphql_params ( deserialization_payload) . await ;
173173 deserialization_payload = result. payload ;
174174 match result. control_flow {
175- ControlFlowResult :: Continue => { /* continue to next plugin */ }
176- ControlFlowResult :: EndResponse ( response) => {
175+ StartControlFlow :: Continue => { /* continue to next plugin */ }
176+ StartControlFlow :: EndResponse ( response) => {
177177 return Ok ( response) ;
178178 }
179- ControlFlowResult :: OnEnd ( callback) => {
179+ StartControlFlow :: OnEnd ( callback) => {
180180 deserialization_end_callbacks. push ( callback) ;
181181 }
182182 }
@@ -190,22 +190,18 @@ pub async fn execute_pipeline(
190190 } ;
191191
192192 if let Some ( plugin_req_state) = & plugin_req_state {
193- let mut payload = OnGraphQLParamsEndPayload {
193+ let mut payload = OnGraphQLParamsEndHookPayload {
194194 graphql_params,
195195 context : & plugin_req_state. context ,
196196 } ;
197197 for deserialization_end_callback in deserialization_end_callbacks {
198198 let result = deserialization_end_callback ( payload) ;
199199 payload = result. payload ;
200200 match result. control_flow {
201- ControlFlowResult :: Continue => { /* continue to next plugin */ }
202- ControlFlowResult :: EndResponse ( response) => {
201+ EndControlFlow :: Continue => { /* continue to next plugin */ }
202+ EndControlFlow :: EndResponse ( response) => {
203203 return Ok ( response) ;
204204 }
205- ControlFlowResult :: OnEnd ( _) => {
206- // on_end callbacks should not return OnEnd again
207- unreachable ! ( "on_end callback returned OnEnd again" ) ;
208- }
209205 }
210206 }
211207 graphql_params = payload. graphql_params ;
0 commit comments