Skip to content

Commit 40fe231

Browse files
committed
fix: use request from gateway instead of serde req
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 450ee8d commit 40fe231

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ where
8080
{
8181
trace!("Handling request for deployment `{manifest_id}`");
8282

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

@@ -112,7 +106,6 @@ where
112106
.process_request(manifest_id, request)
113107
.await
114108
.map_err(IndexerServiceError::ProcessingError)?
115-
.1
116109
.finalize(AttestationOutput::Attestable);
117110
return Ok((StatusCode::OK, response));
118111
};
@@ -179,14 +172,14 @@ where
179172
.cloned()
180173
.ok_or_else(|| (IndexerServiceError::NoSignerForAllocation(allocation_id)))?;
181174

182-
let (request, response) = state
175+
let response = state
183176
.service_impl
184177
.process_request(manifest_id, request)
185178
.await
186179
.map_err(IndexerServiceError::ProcessingError)?;
187180

188-
let req = serde_json::to_string(&request)
189-
.map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
181+
let req =
182+
std::str::from_utf8(&body).map_err(|_| IndexerServiceError::FailedToSignAttestation)?;
190183

191184
let res = response
192185
.as_str()
@@ -195,10 +188,16 @@ where
195188
let attestation = AttestationOutput::Attestation(
196189
response
197190
.is_attestable()
198-
.then(|| signer.create_attestation(&req, res)),
191+
.then(|| signer.create_attestation(req, res)),
199192
);
200193

201194
let response = response.finalize(attestation);
202195

203196
Ok((StatusCode::OK, response))
204197
}
198+
199+
#[derive(Debug, serde::Deserialize, serde::Serialize)]
200+
pub struct QueryBody {
201+
pub query: String,
202+
pub variables: Option<Box<RawValue>>,
203+
}

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)