Skip to content

Commit 1e8cec2

Browse files
chore: rename schema_hash to api_schema_hash
1 parent 7d03132 commit 1e8cec2

File tree

5 files changed

+30
-29
lines changed

5 files changed

+30
-29
lines changed

crates/rover-client/src/operations/graph/publish/runner.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ fn build_response(
9393
};
9494

9595
Ok(GraphPublishResponse {
96-
schema_hash: hash,
96+
api_schema_hash: hash,
9797
change_summary,
9898
})
9999
}
@@ -207,7 +207,7 @@ mod tests {
207207
assert_eq!(
208208
output.unwrap(),
209209
GraphPublishResponse {
210-
schema_hash: "123456".to_string(),
210+
api_schema_hash: "123456".to_string(),
211211
change_summary: ChangeSummary::none(),
212212
}
213213
);

crates/rover-client/src/operations/graph/publish/types.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl From<GitContext> for GraphPublishContextInput {
3939

4040
#[derive(Clone, Serialize, Debug, PartialEq)]
4141
pub struct GraphPublishResponse {
42-
pub schema_hash: String,
42+
pub api_schema_hash: String,
4343
#[serde(flatten)]
4444
pub change_summary: ChangeSummary,
4545
}
@@ -57,17 +57,15 @@ impl ChangeSummary {
5757
type_changes: TypeChanges::none(),
5858
}
5959
}
60+
61+
pub(crate) fn is_none(&self) -> bool {
62+
self.field_changes.is_none() && self.type_changes.is_none()
63+
}
6064
}
6165

6266
impl fmt::Display for ChangeSummary {
6367
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
64-
if self.field_changes.additions == 0
65-
&& self.field_changes.removals == 0
66-
&& self.field_changes.edits == 0
67-
&& self.type_changes.additions == 0
68-
&& self.type_changes.removals == 0
69-
&& self.type_changes.edits == 0
70-
{
68+
if self.is_none() {
7169
write!(f, "[No Changes]")
7270
} else {
7371
write!(f, "[{}, {}]", &self.field_changes, &self.type_changes)
@@ -90,6 +88,10 @@ impl FieldChanges {
9088
edits: 0,
9189
}
9290
}
91+
92+
pub(crate) fn is_none(&self) -> bool {
93+
self.additions == 0 && self.removals == 0 && self.edits == 0
94+
}
9395
}
9496

9597
impl fmt::Display for FieldChanges {
@@ -117,6 +119,10 @@ impl TypeChanges {
117119
edits: 0,
118120
}
119121
}
122+
123+
pub(crate) fn is_none(&self) -> bool {
124+
self.additions == 0 && self.removals == 0 && self.edits == 0
125+
}
120126
}
121127

122128
impl fmt::Display for TypeChanges {

crates/rover-client/src/operations/subgraph/publish/runner.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn build_response(publish_response: UpdateResponse) -> SubgraphPublishResponse {
7272
.collect();
7373

7474
SubgraphPublishResponse {
75-
schema_hash: match publish_response.composition_config {
75+
api_schema_hash: match publish_response.composition_config {
7676
Some(config) => Some(config.schema_hash),
7777
None => None,
7878
},
@@ -110,7 +110,7 @@ mod tests {
110110
assert_eq!(
111111
output,
112112
SubgraphPublishResponse {
113-
schema_hash: Some("5gf564".to_string()),
113+
api_schema_hash: Some("5gf564".to_string()),
114114
composition_errors: vec![
115115
CompositionError {
116116
message: "[Accounts] User -> composition error".to_string(),
@@ -142,7 +142,7 @@ mod tests {
142142
assert_eq!(
143143
output,
144144
SubgraphPublishResponse {
145-
schema_hash: Some("5gf564".to_string()),
145+
api_schema_hash: Some("5gf564".to_string()),
146146
composition_errors: CompositionErrors::new(),
147147
supergraph_was_updated: true,
148148
subgraph_was_created: true,
@@ -169,7 +169,7 @@ mod tests {
169169
assert_eq!(
170170
output,
171171
SubgraphPublishResponse {
172-
schema_hash: None,
172+
api_schema_hash: None,
173173
composition_errors: vec![CompositionError {
174174
message: "[Accounts] -> Things went really wrong".to_string(),
175175
code: None

crates/rover-client/src/operations/subgraph/publish/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct SubgraphPublishInput {
2323

2424
#[derive(Debug, Clone, Serialize, PartialEq)]
2525
pub struct SubgraphPublishResponse {
26-
pub schema_hash: Option<String>,
26+
pub api_schema_hash: Option<String>,
2727

2828
// we skip serializing this field as it is merged with "success"
2929
// at the top level

src/command/output.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ impl RoverOutput {
8585
} => {
8686
eprintln!(
8787
"{}#{} Published successfully {}",
88-
graph_ref, publish_response.schema_hash, publish_response.change_summary
88+
graph_ref, publish_response.api_schema_hash, publish_response.change_summary
8989
);
9090
print_one_line_descriptor("Schema Hash");
91-
print_content(&publish_response.schema_hash);
91+
print_content(&publish_response.api_schema_hash);
9292
}
9393
RoverOutput::SubgraphPublishResponse {
9494
graph_ref,
@@ -119,9 +119,7 @@ impl RoverOutput {
119119
if !publish_response.composition_errors.is_empty() {
120120
let warn_prefix = Red.normal().paint("WARN:");
121121
eprintln!("{} The following composition errors occurred:", warn_prefix,);
122-
for error in publish_response.composition_errors.clone() {
123-
eprintln!("{}", &error);
124-
}
122+
eprintln!("{}", &publish_response.composition_errors);
125123
}
126124
}
127125
RoverOutput::SubgraphDeleteResponse {
@@ -139,9 +137,8 @@ impl RoverOutput {
139137
Cyan.normal().paint(subgraph),
140138
Cyan.normal().paint(graph_ref.to_string()),
141139
);
142-
for error in delete_response.composition_errors.clone() {
143-
eprintln!("{}", &error);
144-
}
140+
141+
eprintln!("{}", &delete_response.composition_errors);
145142
eprintln!("{} This is only a prediction. If the graph changes before confirming, these errors could change.", warn_prefix);
146143
} else {
147144
eprintln!("{} At the time of checking, there would be no composition errors resulting from the deletion of this subgraph.", warn_prefix);
@@ -168,9 +165,7 @@ impl RoverOutput {
168165
warn_prefix,
169166
);
170167

171-
for error in delete_response.composition_errors.clone() {
172-
eprintln!("{}", &error);
173-
}
168+
eprintln!("{}", &delete_response.composition_errors);
174169
}
175170
}
176171
}
@@ -675,7 +670,7 @@ mod tests {
675670
#[test]
676671
fn graph_publish_response_json() {
677672
let mock_publish_response = GraphPublishResponse {
678-
schema_hash: "123456".to_string(),
673+
api_schema_hash: "123456".to_string(),
679674
change_summary: ChangeSummary {
680675
field_changes: FieldChanges {
681676
additions: 2,
@@ -721,7 +716,7 @@ mod tests {
721716
#[test]
722717
fn subgraph_publish_success_response_json() {
723718
let mock_publish_response = SubgraphPublishResponse {
724-
schema_hash: Some("123456".to_string()),
719+
api_schema_hash: Some("123456".to_string()),
725720

726721
composition_errors: CompositionErrors::new(),
727722
supergraph_was_updated: true,
@@ -752,7 +747,7 @@ mod tests {
752747
#[test]
753748
fn subgraph_publish_failure_response_json() {
754749
let mock_publish_response = SubgraphPublishResponse {
755-
schema_hash: None,
750+
api_schema_hash: None,
756751

757752
composition_errors: vec![
758753
CompositionError {

0 commit comments

Comments
 (0)