Skip to content

Commit

Permalink
graphql: Make sure validation errors get logged with subgraph and que…
Browse files Browse the repository at this point in the history
…ry_id
  • Loading branch information
lutter committed Oct 4, 2022
1 parent ef75f31 commit 4c4cb45
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions graphql/src/execution/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,20 @@ impl Query {
max_depth: u8,
metrics: Arc<dyn GraphQLMetrics>,
) -> Result<Arc<Self>, Vec<QueryExecutionError>> {
let query_hash = {
let mut hasher = DefaultHasher::new();
query.query_text.hash(&mut hasher);
query.variables_text.hash(&mut hasher);
hasher.finish()
};
let query_id = format!("{:x}-{:x}", query.shape_hash, query_hash);
let logger = logger.new(o!(
"subgraph_id" => schema.id().clone(),
"query_id" => query_id.clone()
));

let validation_phase_start = Instant::now();
validate_query(logger, &query, &schema.document())?;
validate_query(&logger, &query, &schema.document())?;
metrics.observe_query_validation(validation_phase_start.elapsed(), schema.id());

let mut operation = None;
Expand Down Expand Up @@ -219,18 +231,6 @@ impl Query {
}
};

let query_hash = {
let mut hasher = DefaultHasher::new();
query.query_text.hash(&mut hasher);
query.variables_text.hash(&mut hasher);
hasher.finish()
};
let query_id = format!("{:x}-{:x}", query.shape_hash, query_hash);
let logger = logger.new(o!(
"subgraph_id" => schema.id().clone(),
"query_id" => query_id.clone()
));

let start = Instant::now();
let root_type = match kind {
Kind::Query => schema.query_type.as_ref(),
Expand Down

0 comments on commit 4c4cb45

Please sign in to comment.