Skip to content

Commit

Permalink
Merge pull request #287 from apollographql/igni/tracing_debug
Browse files Browse the repository at this point in the history
qol: move a couple of printlns to tracing debug
  • Loading branch information
o0Ignition0o authored Dec 12, 2023
2 parents 6a1f132 + a192b5e commit 064cb6e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
11 changes: 7 additions & 4 deletions apollo-router/src/plugins/connectors/subgraph_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ where
connector.create_requests(request, Arc::from(schema.definitions.clone()))?;

let tasks = requests.into_iter().map(|(req, res_params)| async {
println!("HTTP {} {}", &req.method(), &req.uri());
tracing::debug!(method = &req.method().as_str(), uri = req.uri().to_string());
let mut res = client.request(req).await?;
res.extensions_mut().insert(res_params);
Ok::<_, BoxError>(res)
Expand All @@ -246,7 +246,10 @@ where
let subgraph_response = connector
.map_http_responses(responses, context, hack_entity_response_key) // 4.
.await?;
dbg!(&subgraph_response.response.body().data);
tracing::debug!(
data = serde_json::to_string(&subgraph_response.response.body().data)
.unwrap_or_else(|e| e.to_string())
);

Ok(subgraph_response)

Expand Down Expand Up @@ -335,7 +338,7 @@ mod tests {
.body(String::new())
.unwrap())
};
println!("generated service response: {res:?}");
tracing::debug!("generated service response: {res:?}");
res
}

Expand All @@ -351,7 +354,7 @@ mod tests {
let _spawned_task = tokio::task::spawn(emulate_rest_connector(listener));

let schema = SCHEMA.replace(
"https://ipinfo.io/",
"https://ipinfo.io",
&format!("http://127.0.0.1:{}/", address.port()),
);

Expand Down
4 changes: 4 additions & 0 deletions apollo-router/src/query_planner/bridge_query_planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ impl BridgeQueryPlanner {
node.generate_connector_plan(&self.subgraph_schemas, &self.subgraph_planners)
.await?;
}
tracing::debug!(
query = original_query,
plan = serde_json::to_string(&plan.data.query_plan.node).unwrap()
);
plan
}
Err(err) => {
Expand Down
7 changes: 4 additions & 3 deletions apollo-router/src/query_planner/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,10 @@ impl FetchNode {
subgraph_planners: &HashMap<String, Arc<Planner<QueryPlanResult>>>,
) -> Result<(), QueryPlannerError> {
if let Some(planner) = subgraph_planners.get(&self.service_name) {
println!(
tracing::debug!(
"planning for subgraph '{}' and query '{}'",
self.service_name, self.operation
self.service_name,
self.operation
);

let (operation, magic_finder_field) =
Expand All @@ -526,7 +527,7 @@ impl FetchNode {
None => (self.operation.clone(), None),
};

println!(
tracing::debug!(
"replaced with operation(magic finder field={magic_finder_field:?}): {operation}"
);
match planner
Expand Down
2 changes: 1 addition & 1 deletion examples/connectors/starstuff.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ schema
directives: [
{
name: "sourceAPI"
args: { name: "ipinfo", http: { baseURL: "https://ipinfo.io/" } }
args: { name: "ipinfo", http: { baseURL: "https://ipinfo.io" } }
}
]
) {
Expand Down

0 comments on commit 064cb6e

Please sign in to comment.