diff --git a/crates/core-subsystem/core-resolver/src/validation/operation_validator.rs b/crates/core-subsystem/core-resolver/src/validation/operation_validator.rs index 22ae94c17..9adfb6db2 100644 --- a/crates/core-subsystem/core-resolver/src/validation/operation_validator.rs +++ b/crates/core-subsystem/core-resolver/src/validation/operation_validator.rs @@ -74,7 +74,11 @@ impl<'a> OperationValidator<'a> { self.normal_query_depth_limit }; if depth > max_depth { - Err(ValidationError::SelectionSetTooDeep(pos)) + Err(ValidationError::SelectionSetTooDeep { + depth, + max_depth, + pos, + }) } else { Ok(true) } diff --git a/crates/core-subsystem/core-resolver/src/validation/snapshots/introspection_query_depth_limit_direct-2.snap b/crates/core-subsystem/core-resolver/src/validation/snapshots/introspection_query_depth_limit_direct-2.snap index 06a51ab55..e9dc05391 100644 --- a/crates/core-subsystem/core-resolver/src/validation/snapshots/introspection_query_depth_limit_direct-2.snap +++ b/crates/core-subsystem/core-resolver/src/validation/snapshots/introspection_query_depth_limit_direct-2.snap @@ -3,7 +3,9 @@ source: crates/core-subsystem/core-resolver/src/validation/document_validator.rs expression: validator.validate(create_query_document(query)) --- Err( - SelectionSetTooDeep( - Pos(5:25), - ), + SelectionSetTooDeep { + depth: 3, + max_depth: 2, + pos: Pos(5:25), + }, ) diff --git a/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_direct-2.snap b/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_direct-2.snap index 364a8b2e8..000dfcae2 100644 --- a/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_direct-2.snap +++ b/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_direct-2.snap @@ -3,7 +3,9 @@ source: crates/core-subsystem/core-resolver/src/validation/document_validator.rs expression: validator.validate(create_query_document(query)) --- Err( - SelectionSetTooDeep( - Pos(8:37), - ), + SelectionSetTooDeep { + depth: 6, + max_depth: 5, + pos: Pos(8:37), + }, ) diff --git a/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_through_fragment-2.snap b/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_through_fragment-2.snap index afa81024f..e4a680c45 100644 --- a/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_through_fragment-2.snap +++ b/crates/core-subsystem/core-resolver/src/validation/snapshots/query_depth_limit_through_fragment-2.snap @@ -3,7 +3,9 @@ source: crates/core-subsystem/core-resolver/src/validation/document_validator.rs expression: validator.validate(create_query_document(query)) --- Err( - SelectionSetTooDeep( - Pos(14:25), - ), + SelectionSetTooDeep { + depth: 6, + max_depth: 5, + pos: Pos(14:25), + }, ) diff --git a/crates/core-subsystem/core-resolver/src/validation/validation_error.rs b/crates/core-subsystem/core-resolver/src/validation/validation_error.rs index 7e5b2d243..f66a6ae98 100644 --- a/crates/core-subsystem/core-resolver/src/validation/validation_error.rs +++ b/crates/core-subsystem/core-resolver/src/validation/validation_error.rs @@ -72,8 +72,12 @@ pub enum ValidationError { #[error("Fragment cycle detected: {0}")] FragmentCycle(String, Pos), - #[error("Selection set too deep")] - SelectionSetTooDeep(Pos), + #[error("Selection set depth {depth} exceeds the maximum allowed depth {max_depth}")] + SelectionSetTooDeep { + depth: usize, + max_depth: usize, + pos: Pos, + }, #[error("Invalid value for '{value_name}': {range_detail}, {value_detail}")] ValueOutOfRange { @@ -106,7 +110,7 @@ impl ValidationError { ValidationError::MultipleOperationsUnmatchedOperationName(_) => vec![], ValidationError::InvalidArgumentType { pos, .. } => vec![*pos], ValidationError::FragmentCycle(_, pos) => vec![*pos], - ValidationError::SelectionSetTooDeep(pos) => vec![*pos], + ValidationError::SelectionSetTooDeep { pos, .. } => vec![*pos], ValidationError::ValueOutOfRange { pos, .. } => vec![*pos], } } diff --git a/integration-tests/error-reporting/tests/over-the-limit-query-depth.exotest b/integration-tests/error-reporting/tests/over-the-limit-query-depth.exotest index 1b7ea53cb..cddfe8c9c 100644 --- a/integration-tests/error-reporting/tests/over-the-limit-query-depth.exotest +++ b/integration-tests/error-reporting/tests/over-the-limit-query-depth.exotest @@ -23,7 +23,7 @@ response: | { "errors": [ { - "message": "Selection set too deep", + "message": "Selection set depth 6 exceeds the maximum allowed depth 5", "locations": [ { "line": 11,