diff --git a/common/src/indexer_service/http/indexer_service.rs b/common/src/indexer_service/http/indexer_service.rs index d5c3b454..623223ff 100644 --- a/common/src/indexer_service/http/indexer_service.rs +++ b/common/src/indexer_service/http/indexer_service.rs @@ -72,7 +72,7 @@ pub trait IndexerServiceImpl { &self, manifest_id: DeploymentId, request: Request, - ) -> Result<(Request, Self::Response), Self::Error>; + ) -> Result; } #[derive(Debug, Error)] diff --git a/common/src/indexer_service/http/request_handler.rs b/common/src/indexer_service/http/request_handler.rs index 62ae21ce..7a243c3f 100644 --- a/common/src/indexer_service/http/request_handler.rs +++ b/common/src/indexer_service/http/request_handler.rs @@ -4,7 +4,6 @@ use std::sync::Arc; use axum::{ - body::Bytes, extract::{Path, State}, http::HeaderMap, response::IntoResponse, @@ -54,7 +53,7 @@ pub async fn request_handler( typed_header: TypedHeader, state: State>>, headers: HeaderMap, - body: Bytes, + body: String, ) -> Result> where I: IndexerServiceImpl + Sync + Send + 'static, @@ -73,21 +72,15 @@ async fn _request_handler( TypedHeader(receipt): TypedHeader, State(state): State>>, headers: HeaderMap, - body: Bytes, + req: String, ) -> Result> where I: IndexerServiceImpl + Sync + Send + 'static, { trace!("Handling request for deployment `{manifest_id}`"); - #[derive(Debug, serde::Deserialize, serde::Serialize)] - pub struct QueryBody { - pub query: String, - pub variables: Option>, - } - let request: QueryBody = - serde_json::from_slice(&body).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?; + serde_json::from_str(&req).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?; let Some(receipt) = receipt.into_signed_receipt() else { // Serve free query, NO METRICS @@ -112,7 +105,6 @@ where .process_request(manifest_id, request) .await .map_err(IndexerServiceError::ProcessingError)? - .1 .finalize(AttestationOutput::Attestable); return Ok((StatusCode::OK, response)); }; @@ -179,15 +171,12 @@ where .cloned() .ok_or_else(|| (IndexerServiceError::NoSignerForAllocation(allocation_id)))?; - let (request, response) = state + let response = state .service_impl .process_request(manifest_id, request) .await .map_err(IndexerServiceError::ProcessingError)?; - let req = serde_json::to_string(&request) - .map_err(|_| IndexerServiceError::FailedToSignAttestation)?; - let res = response .as_str() .map_err(|_| IndexerServiceError::FailedToSignAttestation)?; @@ -202,3 +191,9 @@ where Ok((StatusCode::OK, response)) } + +#[derive(Debug, serde::Deserialize, serde::Serialize)] +pub struct QueryBody { + pub query: String, + pub variables: Option>, +} diff --git a/service/src/service.rs b/service/src/service.rs index 12504677..2429b628 100644 --- a/service/src/service.rs +++ b/service/src/service.rs @@ -90,7 +90,7 @@ impl IndexerServiceImpl for SubgraphService { &self, deployment: DeploymentId, request: Request, - ) -> Result<(Request, Self::Response), Self::Error> { + ) -> Result { let deployment_url = self .state .graph_node_query_base_url @@ -118,7 +118,7 @@ impl IndexerServiceImpl for SubgraphService { .await .map_err(SubgraphServiceError::QueryForwardingError)?; - Ok((request, SubgraphServiceResponse::new(body, attestable))) + Ok(SubgraphServiceResponse::new(body, attestable)) } }