File tree Expand file tree Collapse file tree 3 files changed +16
-19
lines changed
common/src/indexer_service/http Expand file tree Collapse file tree 3 files changed +16
-19
lines changed Original file line number Diff line number Diff line change @@ -66,15 +66,14 @@ pub enum AttestationOutput {
6666#[ async_trait]
6767pub trait IndexerServiceImpl {
6868 type Error : std:: error:: Error ;
69- type Request : DeserializeOwned + Send + Debug + Serialize ;
7069 type Response : IndexerServiceResponse + Sized ;
7170 type State : Send + Sync ;
7271
73- async fn process_request (
72+ async fn process_request < Request : DeserializeOwned + Send + Debug + Serialize > (
7473 & self ,
7574 manifest_id : DeploymentId ,
76- request : Self :: Request ,
77- ) -> Result < ( Self :: Request , Self :: Response ) , Self :: Error > ;
75+ request : Request ,
76+ ) -> Result < ( Request , Self :: Response ) , Self :: Error > ;
7877}
7978
8079#[ derive( Debug , Error ) ]
Original file line number Diff line number Diff line change 8080{
8181 trace ! ( "Handling request for deployment `{manifest_id}`" ) ;
8282
83- let request =
83+ #[ derive( Debug , serde:: Deserialize , serde:: Serialize ) ]
84+ pub struct QueryBody {
85+ pub query : String ,
86+ pub variables : Option < Box < RawValue > > ,
87+ }
88+
89+ let request: QueryBody =
8490 serde_json:: from_slice ( & body) . map_err ( |e| IndexerServiceError :: InvalidRequest ( e. into ( ) ) ) ?;
8591
8692 let Some ( receipt) = receipt. into_signed_receipt ( ) else {
@@ -113,23 +119,15 @@ where
113119
114120 let allocation_id = receipt. message . allocation_id ;
115121
116- #[ derive( Debug , serde:: Deserialize ) ]
117- pub struct QueryBody {
118- pub query : String ,
119- pub variables : Option < Box < RawValue > > ,
120- }
121-
122- let query_body: QueryBody =
123- serde_json:: from_slice ( & body) . map_err ( |e| IndexerServiceError :: InvalidRequest ( e. into ( ) ) ) ?;
124- let variables = query_body
122+ let variables = request
125123 . variables
126124 . as_ref ( )
127125 . map ( ToString :: to_string)
128126 . unwrap_or_default ( ) ;
129127 let mut ctx = Context :: new ( ) ;
130128 ctx. insert ( AgoraQuery {
131129 deployment_id : manifest_id,
132- query : query_body . query . clone ( ) ,
130+ query : request . query . clone ( ) ,
133131 variables,
134132 } ) ;
135133
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use indexer_common::indexer_service::http::{
1212} ;
1313use indexer_config:: Config as MainConfig ;
1414use reqwest:: Url ;
15+ use serde:: { de:: DeserializeOwned , Serialize } ;
1516use serde_json:: { json, Value } ;
1617use sqlx:: PgPool ;
1718use thegraph_core:: DeploymentId ;
@@ -82,15 +83,14 @@ impl SubgraphService {
8283#[ async_trait]
8384impl IndexerServiceImpl for SubgraphService {
8485 type Error = SubgraphServiceError ;
85- type Request = serde_json:: Value ;
8686 type Response = SubgraphServiceResponse ;
8787 type State = SubgraphServiceState ;
8888
89- async fn process_request (
89+ async fn process_request < Request : DeserializeOwned + Send + std :: fmt :: Debug + Serialize > (
9090 & self ,
9191 deployment : DeploymentId ,
92- request : Self :: Request ,
93- ) -> Result < ( Self :: Request , Self :: Response ) , Self :: Error > {
92+ request : Request ,
93+ ) -> Result < ( Request , Self :: Response ) , Self :: Error > {
9494 let deployment_url = Url :: parse ( & self . state . graph_node_query_base_url )
9595 . expect ( "Invalid `graph_node.query_url` in config" )
9696 . join ( & format ! ( "subgraphs/id/{deployment}" ) )
You can’t perform that action at this time.
0 commit comments