Skip to content

Commit

Permalink
Replace internal connectors subgraph name in errors (#5947)
Browse files Browse the repository at this point in the history
  • Loading branch information
pubmodmatt authored Sep 3, 2024
2 parents 0b67964 + f822648 commit 5477c6a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion apollo-router/src/services/connector_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use super::connect::BoxService;
use super::http::HttpClientServiceFactory;
use super::http::HttpRequest;
use super::new_service::ServiceFactory;
use crate::error::FetchError;
use crate::plugins::connectors::error::Error as ConnectorError;
use crate::plugins::connectors::handle_responses::handle_responses;
use crate::plugins::connectors::http::Response as ConnectorResponse;
Expand Down Expand Up @@ -167,7 +168,24 @@ async fn execute(
http_request: req,
context,
};
let res = client.oneshot(req).await?;
let res = client.oneshot(req).await.map_err(|e| {
match e.downcast::<FetchError>() {
// Replace the internal subgraph name with the connector label
Ok(inner) => match *inner {
FetchError::SubrequestHttpError {
status_code,
service: _,
reason,
} => Box::new(FetchError::SubrequestHttpError {
status_code,
service: connector.id.label.clone(),
reason,
}),
_ => inner,
},
Err(e) => e,
}
})?;

Ok::<_, BoxError>(ConnectorResponse {
result: ConnectorResult::HttpResponse(res.http_response),
Expand Down

0 comments on commit 5477c6a

Please sign in to comment.