Skip to content

Commit

Permalink
Preserve the parts from our subgraph response use in our response
Browse files Browse the repository at this point in the history
Currently, we build a response from only the body of the subgraph
response. This change ensures that the parts from the subgraph response
(headers, status_code, version) are also preserved in the resulting
response from the router.
  • Loading branch information
garypen committed May 18, 2022
1 parent 56bcd77 commit 7f7d223
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apollo-router-core/src/services/tower_subgraph_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ impl tower::Service<graphql::SubgraphRequest> for TowerSubgraphService {
}
})?;

let body = hyper::body::to_bytes(response.into_body())
// Keep our parts, we'll need them later
let (parts, body) = response.into_parts();
let body = hyper::body::to_bytes(body)
.instrument(tracing::debug_span!("aggregate_response_data"))
.await
.map_err(|err| {
Expand All @@ -108,8 +110,10 @@ impl tower::Service<graphql::SubgraphRequest> for TowerSubgraphService {
})
})?;

let resp = http::Response::from_parts(parts, graphql);

Ok(graphql::SubgraphResponse::new_from_response(
http::Response::builder().body(graphql).expect("no argument can fail to parse or converted to the internal representation here; qed").into(),
resp.into(),
context,
))
})
Expand Down

0 comments on commit 7f7d223

Please sign in to comment.