graphql: Refactor `collect_fields` for fragments
@@ -399,7 +399,6 @@ where
// Resolve the fragment using its name and, if it applies, collect
// fields for the fragment and group them
- let fragment_grouped_field_set =
qast::get_fragment(&ctx.document, &spread.fragment_name)
.and_then(|fragment| {
// We have a fragment, only pass it on if it applies to the
@@ -417,28 +416,26 @@ where
.map(|fragment| {
// We have a fragment that applies to the current object type,
// collect its fields into response key groups
- collect_fields(
+ let fragment_grouped_field_set = collect_fields(
ctx.clone(),
object_type,
&fragment.selection_set,
Some(visited_fragments.clone()),
- )
- });
+ );
- if let Some(grouped_field_set) = fragment_grouped_field_set {
// Add all items from each fragments group to the field group
// with the corresponding response key
- for (response_key, mut fragment_group) in grouped_field_set {
+ for (response_key, mut fragment_group) in fragment_grouped_field_set {
grouped_fields
.entry(response_key)
.or_default()
.append(&mut fragment_group);
}
- }
+ });
}
}
- q::Selection::InlineFragment(_) => {
+ q::Selection::InlineFragment(_fragment) => {
warn!(ctx.logger, "Inline fragments are not yet implemented")
}
};
