Skip to content

Commit f2ddead

Browse files
committed
move reason handling to if let so it is clear that we only handle the arguments if we have that present
1 parent 22e9607 commit f2ddead

File tree

1 file changed

+6
-7
lines changed
  • crates/apollo-mcp-server/src/introspection

1 file changed

+6
-7
lines changed

crates/apollo-mcp-server/src/introspection/minify.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,19 @@ fn minify_directives(directives: &apollo_compiler::ast::DirectiveList) -> String
8282

8383
for directive in directives.iter() {
8484
if let Some(minified_name) = directives_to_minify.get(directive.name.as_str()) {
85-
if !directive.arguments.is_empty() {
86-
// Since we're only handling @deprecated right now we can just add the reason and minify it.
87-
// We should handle this more generically in the future.
88-
let reason = directive
85+
// Since we're only handling @deprecated right now we can just add the reason and minify it.
86+
// We should handle this more generically in the future.
87+
if !directive.arguments.is_empty()
88+
&& let Some(reason) = directive
8989
.arguments
9090
.iter()
9191
.find(|a| a.name == "reason")
9292
.and_then(|a| a.value.as_str())
93-
.unwrap_or("No longer supported")
94-
.to_string();
93+
{
9594
result.push_str(&format!(
9695
"@{}(\"{}\")",
9796
minified_name,
98-
normalize_description(&reason)
97+
normalize_description(reason)
9998
));
10099
} else {
101100
result.push_str(&format!("@{}", minified_name));

0 commit comments

Comments
 (0)