Skip to content

Commit ac51b46

Browse files
author
daniel.eades
committed
collapse some 'if else' blocks
1 parent 44ac38d commit ac51b46

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

graphql_client_codegen/src/query/validation.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ pub(super) fn validate_typename_presence(
55
query: &BoundQuery<'_>,
66
) -> Result<(), QueryValidationError> {
77
for fragment in &query.query.fragments {
8-
let type_id = match fragment.on {
9-
id @ (TypeId::Interface(_) | TypeId::Union(_)) => id,
10-
_ => continue,
8+
let type_id @ (TypeId::Interface(_) | TypeId::Union(_)) = fragment.on else {
9+
continue;
1110
};
1211

1312
if !selection_set_contains_type_name(fragment.on, &fragment.selection_set, query.query) {
@@ -23,14 +22,15 @@ pub(super) fn validate_typename_presence(
2322
query
2423
.query
2524
.selections()
26-
.filter_map(|(selection_id, selection)| match selection {
27-
Selection::Field(field) => match query.schema.get_field(field.field_id).r#type.id {
28-
id @ (TypeId::Interface(_) | TypeId::Union(_)) => {
29-
Some((selection_id, id, &field.selection_set))
25+
.filter_map(|(selection_id, selection)| {
26+
if let Selection::Field(field) = selection {
27+
let field_type_id = query.schema.get_field(field.field_id).r#type.id;
28+
29+
if matches!(field_type_id, TypeId::Interface(_) | TypeId::Union(_)) {
30+
return Some((selection_id, field_type_id, &field.selection_set));
3031
}
31-
_ => None,
32-
},
33-
_ => None,
32+
}
33+
None
3434
});
3535

3636
for selection in union_and_interface_field_selections {

0 commit comments

Comments
 (0)