Skip to content

Commit fdeda9f

Browse files
authored
fix: use request from gateway instead of serde req (#464)
1 parent 450ee8d commit fdeda9f

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

common/src/indexer_service/http/indexer_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub trait IndexerServiceImpl {
7272
&self,
7373
manifest_id: DeploymentId,
7474
request: Request,
75-
) -> Result<(Request, Self::Response), Self::Error>;
75+
) -> Result<Self::Response, Self::Error>;
7676
}
7777

7878
#[derive(Debug, Error)]

common/src/indexer_service/http/request_handler.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
use std::sync::Arc;
55

66
use axum::{
7-
body::Bytes,
87
extract::{Path, State},
98
http::HeaderMap,
109
response::IntoResponse,
@@ -54,7 +53,7 @@ pub async fn request_handler<I>(
5453
typed_header: TypedHeader<TapReceipt>,
5554
state: State<Arc<IndexerServiceState<I>>>,
5655
headers: HeaderMap,
57-
body: Bytes,
56+
body: String,
5857
) -> Result<impl IntoResponse, IndexerServiceError<I::Error>>
5958
where
6059
I: IndexerServiceImpl + Sync + Send + 'static,
@@ -73,21 +72,15 @@ async fn _request_handler<I>(
7372
TypedHeader(receipt): TypedHeader<TapReceipt>,
7473
State(state): State<Arc<IndexerServiceState<I>>>,
7574
headers: HeaderMap,
76-
body: Bytes,
75+
req: String,
7776
) -> Result<impl IntoResponse, IndexerServiceError<I::Error>>
7877
where
7978
I: IndexerServiceImpl + Sync + Send + 'static,
8079
{
8180
trace!("Handling request for deployment `{manifest_id}`");
8281

83-
#[derive(Debug, serde::Deserialize, serde::Serialize)]
84-
pub struct QueryBody {
85-
pub query: String,
86-
pub variables: Option<Box<RawValue>>,
87-
}
88-
8982
let request: QueryBody =
90-
serde_json::from_slice(&body).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?;
83+
serde_json::from_str(&req).map_err(|e| IndexerServiceError::InvalidRequest(e.into()))?;
9184

9285
let Some(receipt) = receipt.into_signed_receipt() else {
9386
// Serve free query, NO METRICS
@@ -112,7 +105,6 @@ where
112105
.process_request(manifest_id, request)
113106
.await
114107
.map_err(IndexerServiceError::ProcessingError)?
115-
.1
116108
.finalize(AttestationOutput::Attestable);
117109
return Ok((StatusCode::OK, response));
118110
};
@@ -179,15 +171,12 @@ where
179171
.cloned()
180172
.ok_or_else(|| (IndexerServiceError::NoSignerForAllocation(allocation_id)))?;
181173

182-
let (request, response) = state
174+
let response = state
183175
.service_impl
184176
.process_request(manifest_id, request)
185177
.await
186178
.map_err(IndexerServiceError::ProcessingError)?;
187179

188-
let req = serde_json::to_string(&request)
189-
.map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
190-
191180
let res = response
192181
.as_str()
193182
.map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
@@ -202,3 +191,9 @@ where
202191

203192
Ok((StatusCode::OK, response))
204193
}
194+
195+
#[derive(Debug, serde::Deserialize, serde::Serialize)]
196+
pub struct QueryBody {
197+
pub query: String,
198+
pub variables: Option<Box<RawValue>>,
199+
}

service/src/service.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl IndexerServiceImpl for SubgraphService {
9090
&self,
9191
deployment: DeploymentId,
9292
request: Request,
93-
) -> Result<(Request, Self::Response), Self::Error> {
93+
) -> Result<Self::Response, Self::Error> {
9494
let deployment_url = self
9595
.state
9696
.graph_node_query_base_url
@@ -118,7 +118,7 @@ impl IndexerServiceImpl for SubgraphService {
118118
.await
119119
.map_err(SubgraphServiceError::QueryForwardingError)?;
120120

121-
Ok((request, SubgraphServiceResponse::new(body, attestable)))
121+
Ok(SubgraphServiceResponse::new(body, attestable))
122122
}
123123
}
124124

0 commit comments

Comments
 (0)