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

Improve messaging for rover subgraph check #980

Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions crates/rover-client/src/operations/graph/check/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@ fn get_check_response_from_data(
changes.push(change.into());
}

// The `graph` check response does not return this field
// only `subgraph` check does. Since `CheckResponse` is shared
// between `graph` and `subgraph` checks, defaulting this
// to false for now since its currently only used in
// `check_response.rs` to format better console messages.
let core_schema_modified = false;

CheckResponse::try_new(
target_url,
operation_check_count,
changes,
result,
graph_ref,
core_schema_modified,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
}
targetUrl
}
coreSchemaModified
}
}
}
3 changes: 3 additions & 0 deletions crates/rover-client/src/operations/subgraph/check/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,15 @@ fn get_check_response_from_data(
});
}

let core_schema_modified = service.check_partial_schema.core_schema_modified;

CheckResponse::try_new(
check_schema_result.target_url,
operation_check_count,
changes,
result,
graph_ref,
core_schema_modified,
)
} else {
let num_failures = query_composition_errors.len();
Expand Down
11 changes: 10 additions & 1 deletion crates/rover-client/src/shared/check_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub struct CheckResponse {
#[serde(skip_serializing)]
result: ChangeSeverity,
failure_count: u64,
core_schema_modified: bool,
}

impl CheckResponse {
Expand All @@ -30,6 +31,7 @@ impl CheckResponse {
changes: Vec<SchemaChange>,
result: ChangeSeverity,
graph_ref: GraphRef,
core_schema_modified: bool,
) -> Result<CheckResponse, RoverClientError> {
let mut failure_count = 0;
for change in &changes {
Expand All @@ -44,6 +46,7 @@ impl CheckResponse {
changes,
result,
failure_count,
core_schema_modified,
};

match failure_count.cmp(&0) {
Expand All @@ -60,7 +63,13 @@ impl CheckResponse {
let num_changes = self.changes.len();

let mut msg = match num_changes {
0 => "There were no changes detected in the composed schema.".to_string(),
0 => {
if self.core_schema_modified {
"There were no changes detected in the composed API schema, but the core schema was modified.".to_string()
} else {
"There were no changes detected in the composed schema.".to_string()
}
}
_ => format!(
"Compared {} schema changes against {} operations",
num_changes, self.operation_check_count
Expand Down
7 changes: 6 additions & 1 deletion src/command/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ mod tests {
],
ChangeSeverity::PASS,
graph_ref,
true,
);
if let Ok(mock_check_response) = mock_check_response {
let actual_json: JsonOutput = RoverOutput::CheckResponse(mock_check_response).into();
Expand All @@ -789,6 +790,7 @@ mod tests {
],
"failure_count": 0,
"success": true,
"core_schema_modified": true,
},
"error": null
});
Expand Down Expand Up @@ -819,7 +821,9 @@ mod tests {
severity: ChangeSeverity::FAIL,
}
],
ChangeSeverity::FAIL, graph_ref);
ChangeSeverity::FAIL, graph_ref,
false,
);

if let Err(operation_check_failure) = check_response {
let actual_json: JsonOutput = RoverError::new(operation_check_failure).into();
Expand All @@ -843,6 +847,7 @@ mod tests {
],
"failure_count": 2,
"success": false,
"core_schema_modified": false,
},
"error": {
"message": "This operation check has encountered 2 schema changes that would break operations from existing client traffic.",
Expand Down