Skip to content

Commit

Permalink
Lint + take in feedback around operation name
Browse files Browse the repository at this point in the history
  • Loading branch information
bryn committed Apr 19, 2022
1 parent ec1e960 commit 326e330
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
15 changes: 0 additions & 15 deletions apollo-router/src/axum_http_server_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,21 +510,6 @@ async fn run_graphql_request(
}
}

fn get_operation_name(http_request: &Request<graphql::Request>) -> String {
http_request
.body()
.operation_name
.clone()
.or_else(|| {
http_request
.uri()
.query()
.and_then(|query| graphql::Request::from_urlencoded_query(query.to_string()).ok())
.and_then(|q| q.operation_name)
})
.unwrap_or_default()
}

fn prefers_html(accept_header: &HeaderValue) -> bool {
accept_header
.to_str()
Expand Down
12 changes: 11 additions & 1 deletion apollo-router/src/plugins/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::plugins::telemetry::metrics::{
use crate::plugins::telemetry::tracing::TracingConfigurator;
use crate::subscriber::replace_layer;
use ::tracing::{info_span, Span};
use apollo_router_core::prelude::graphql;
use apollo_router_core::{
http_compat, register_plugin, ExecutionRequest, ExecutionResponse, Handler, Plugin,
QueryPlannerRequest, QueryPlannerResponse, ResponseBody, RouterRequest, RouterResponse,
Expand Down Expand Up @@ -462,7 +463,16 @@ impl Telemetry {
.body()
.operation_name
.clone()
.unwrap_or_else(|| "".to_string());
.or_else(|| {
http_request
.url()
.query()
.and_then(|query| {
graphql::Request::from_urlencoded_query(query.to_string()).ok()
})
.and_then(|q| q.operation_name)
})
.unwrap_or_default();
let client_name = headers
.get(&client_name_header)
.cloned()
Expand Down

0 comments on commit 326e330

Please sign in to comment.