Skip to content

Commit 619abae

Browse files
committed
getting there
1 parent dad2579 commit 619abae

17 files changed

+92
-95
lines changed

lib/query-planner/src/ast/minification/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ pub enum MinificationError {
66
FieldNotFound(String, String),
77
#[error("Unsupported fragment spread")]
88
UnsupportedFragmentSpread,
9-
#[error("Unsupported field in `_entities`: {0}")]
10-
UnsupportedFieldInEntities(String),
9+
#[error("Unsupported field in `_entities`: {0}.{1}")]
10+
UnsupportedFieldInEntities(String, String),
1111
}

lib/query-planner/src/ast/minification/stats.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ fn walk_and_collect_stats(
9090
}
9191

9292
return Err(MinificationError::UnsupportedFieldInEntities(
93+
type_def.name().to_string(),
9394
field.name.clone(),
9495
));
9596
}

lib/query-planner/src/ast/minification/transform.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ fn transform_field(
185185
}
186186

187187
return Err(MinificationError::UnsupportedFieldInEntities(
188+
type_name.to_string(),
188189
field.name.clone(),
189190
));
190191
}

lib/query-planner/src/ast/safe_merge.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ mod tests {
409409
let mut merger = SafeSelectionSetMerger::default();
410410
let merge_locations = merger.merge_selection_set(&mut a, &b, (false, true), false);
411411
assert_eq!(merge_locations.len(), 1);
412-
insta::assert_snapshot!(merge_locations[0].0, @"''->p.a");
412+
insta::assert_snapshot!(merge_locations[0].0, @"p.a");
413413
insta::assert_snapshot!(merge_locations[0].1, @"_internal_qp_alias_0");
414414
}
415415
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ fn create_noop_fetch_step(
268268
selection_set: SelectionSet::default(),
269269
type_name: "*".to_string(),
270270
},
271-
output_new: FetchStepSelections::empty(),
271+
output_new: FetchStepSelections::new_empty(),
272272
used_for_requires: created_from_requires,
273273
condition: None,
274274
kind: FetchStepKind::Root,
@@ -745,10 +745,6 @@ fn process_entity_move_edge(
745745
fetch_path,
746746
)?;
747747

748-
println!(
749-
"process_children_for_fetch_steps: output_type_name={}, response_path={}",
750-
output_type_name, response_path
751-
);
752748
process_children_for_fetch_steps(
753749
graph,
754750
fetch_graph,

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

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<State> Display for FetchStepData<State> {
5757
write!(f, "{}/{} ", def_name, selections)?;
5858
}
5959

60-
write!(f, " at $.{}", self.response_path.join("."));
60+
write!(f, " at $.{}", self.response_path.join("."))?;
6161

6262
if self.used_for_requires {
6363
write!(f, " [@requires]")?;
@@ -106,31 +106,13 @@ impl<State> FetchStepData<State> {
106106
}
107107
}
108108

109-
impl FetchStepData<SingleTypeFetchStep> {
110-
pub fn into_multi_type(self) -> FetchStepData<MultiTypeFetchStep> {
111-
FetchStepData::<MultiTypeFetchStep> {
112-
service_name: self.service_name,
113-
response_path: self.response_path,
114-
input: self.input,
115-
output_new: self.output_new.into_multi_type(),
116-
kind: self.kind,
117-
used_for_requires: self.used_for_requires,
118-
condition: self.condition,
119-
variable_usages: self.variable_usages,
120-
variable_definitions: self.variable_definitions,
121-
mutation_field_position: self.mutation_field_position,
122-
input_rewrites: self.input_rewrites,
123-
output_rewrites: self.output_rewrites,
124-
internal_aliases_locations: self.internal_aliases_locations,
125-
}
126-
}
127-
109+
impl FetchStepData<MultiTypeFetchStep> {
128110
pub fn can_merge(
129111
&self,
130112
self_index: NodeIndex,
131113
other_index: NodeIndex,
132114
other: &Self,
133-
fetch_graph: &FetchGraph<SingleTypeFetchStep>,
115+
fetch_graph: &FetchGraph<MultiTypeFetchStep>,
134116
) -> bool {
135117
if self_index == other_index {
136118
return false;
@@ -191,3 +173,23 @@ impl FetchStepData<SingleTypeFetchStep> {
191173
true
192174
}
193175
}
176+
177+
impl FetchStepData<SingleTypeFetchStep> {
178+
pub fn into_multi_type(self) -> FetchStepData<MultiTypeFetchStep> {
179+
FetchStepData::<MultiTypeFetchStep> {
180+
service_name: self.service_name,
181+
response_path: self.response_path,
182+
input: self.input,
183+
output_new: self.output_new.into_multi_type(),
184+
kind: self.kind,
185+
used_for_requires: self.used_for_requires,
186+
condition: self.condition,
187+
variable_usages: self.variable_usages,
188+
variable_definitions: self.variable_definitions,
189+
mutation_field_position: self.mutation_field_position,
190+
input_rewrites: self.input_rewrites,
191+
output_rewrites: self.output_rewrites,
192+
internal_aliases_locations: self.internal_aliases_locations,
193+
}
194+
}
195+
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use crate::{
77
selection_item::SelectionItem,
88
type_aware_selection::find_selection_set_by_path_mut,
99
},
10-
planner::fetch::{error::FetchGraphError, fetch_graph::FetchGraph},
10+
planner::fetch::{error::FetchGraphError, fetch_graph::FetchGraph, state::MultiTypeFetchStep},
1111
};
1212

13-
impl FetchGraph {
13+
impl FetchGraph<MultiTypeFetchStep> {
1414
/// This method applies internal aliasing for fields in the fetch graph.
1515
/// In case a fetch step contains a record of alias made to an output field, it needs to be propagated to all descendants steps that depends on this
1616
/// output field, in multiple locations:
@@ -132,13 +132,7 @@ impl FetchGraph {
132132
new_path.get_mut(segment_idx_to_patch)
133133
{
134134
*name = new_name.clone();
135-
decendent.response_path = MergePath::new(
136-
decendent
137-
.response_path
138-
.entrypoint_definition_name
139-
.clone(),
140-
new_path,
141-
);
135+
decendent.response_path = MergePath::new(new_path);
142136
}
143137
}
144138
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use tracing::{instrument, trace};
66

77
use crate::planner::fetch::{
88
error::FetchGraphError, fetch_graph::FetchGraph,
9-
optimize::utils::is_reachable_via_alternative_upstream_path,
9+
optimize::utils::is_reachable_via_alternative_upstream_path, state::MultiTypeFetchStep,
1010
};
1111

12-
impl FetchGraph {
12+
impl FetchGraph<MultiTypeFetchStep> {
1313
/// Removes redundant direct dependencies from a FetchStep graph.
1414
///
1515
/// ```text

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use tracing::{instrument, trace};
55

66
use crate::planner::fetch::{
77
error::FetchGraphError, fetch_graph::FetchGraph, optimize::utils::perform_fetch_step_merge,
8+
state::MultiTypeFetchStep,
89
};
910

10-
impl FetchGraph {
11+
impl FetchGraph<MultiTypeFetchStep> {
1112
#[instrument(level = "trace", skip_all)]
1213
pub(crate) fn merge_children_with_parents(&mut self) -> Result<(), FetchGraphError> {
1314
let root_index = self

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ use crate::{
55
ast::type_aware_selection::find_arguments_conflicts,
66
planner::fetch::{
77
error::FetchGraphError, fetch_graph::FetchGraph, fetch_step_data::FetchStepData,
8-
optimize::utils::perform_fetch_step_merge,
8+
optimize::utils::perform_fetch_step_merge, state::MultiTypeFetchStep,
99
},
1010
};
1111

12-
impl FetchStepData {
12+
impl FetchStepData<MultiTypeFetchStep> {
1313
pub fn can_merge_leafs(
1414
&self,
1515
self_index: NodeIndex,
1616
other_index: NodeIndex,
1717
other: &Self,
18-
fetch_graph: &FetchGraph,
18+
fetch_graph: &FetchGraph<MultiTypeFetchStep>,
1919
) -> bool {
2020
if self_index == other_index {
2121
return false;
@@ -66,7 +66,7 @@ impl FetchStepData {
6666
}
6767
}
6868

69-
impl FetchGraph {
69+
impl FetchGraph<MultiTypeFetchStep> {
7070
#[instrument(level = "trace", skip_all)]
7171
/// This optimization is about merging leaf nodes in the fetch nodes with other nodes.
7272
/// It reduces the number of fetch steps, without degrading the query performance.

0 commit comments

Comments
 (0)