Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql: Make sure validation errors get logged with subgraph and query_id #4031

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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