Skip to content

Commit dad2579

Browse files
committed
ok
1 parent 3f426b6 commit dad2579

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/query-planner/src/planner/fetch/optimize/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(crate) fn perform_fetch_step_merge(
5050
me.condition = other.condition.take();
5151
}
5252

53-
let scoped_aliases = me.output_new.safe_add_from_another_at_path(
53+
let scoped_aliases = me.output_new.safe_migrate_from_another(
5454
&other.output_new,
5555
&other.response_path.slice_from(me.response_path.len()),
5656
(me.used_for_requires, other.used_for_requires),

lib/query-planner/src/planner/fetch/selections.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,19 @@ impl FetchStepSelections<MultiTypeFetchStep> {
176176
merge_selection_set(selections, selection_set, false);
177177
}
178178

179-
pub fn safe_add_from_another_at_path(
179+
pub fn safe_migrate_from_another(
180180
&mut self,
181181
other: &Self,
182182
fetch_path: &MergePath,
183183
(self_used_for_requires, other_used_for_requires): (bool, bool),
184184
) -> Vec<(String, AliasesRecords)> {
185185
let mut aliases_made: Vec<(String, AliasesRecords)> = Vec::new();
186+
let maybe_merge_into = self.try_as_single().map(|str| str.to_string());
186187

187188
for (definition_name, selection_set) in other.iter_selections() {
188-
// let target_type_name = self
189-
// .get_definition_to_modify(fetch_path, definition_name)
190-
// .to_string();
189+
let target_type = maybe_merge_into.as_ref().unwrap_or(definition_name);
191190
let current = self
192-
.selections_for_definition_mut(&definition_name)
191+
.selections_for_definition_mut(&target_type)
193192
.expect("missing");
194193

195194
if let Some(selection_at_path) = find_selection_set_by_path_mut(current, fetch_path) {
@@ -202,13 +201,13 @@ impl FetchStepSelections<MultiTypeFetchStep> {
202201
);
203202

204203
if !current_aliases_made.is_empty() {
205-
aliases_made.push((definition_name.to_string(), current_aliases_made));
204+
aliases_made.push((target_type.to_string(), current_aliases_made));
206205
}
207206
} else {
208207
// TODO: Replace with error handling
209208
panic!(
210209
"[{}]: Path '{}' cannot be found in selection set: '{}'",
211-
definition_name, fetch_path, current
210+
target_type, fetch_path, current
212211
);
213212
}
214213
}

0 commit comments

Comments
 (0)