Skip to content

Commit

Permalink
Move current_dir check from execute_recursively to fetch_node
Browse files Browse the repository at this point in the history
  • Loading branch information
Ty3uK committed Jun 30, 2022
1 parent c70b006 commit c228ce9
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions apollo-router/src/query_planner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,22 +167,6 @@ impl PlanNode {
let mut value;
let mut errors;

if !current_dir.is_empty() {
// Check if parent data has field requested by Flatten
match parent_value.pointer(&current_dir.to_string()) {
Some(matched_value) => {
// If it's not we don't need to run underlying fetch
if matched_value.is_null() {
return (
Value::default(),
Vec::new(),
)
}
}
_ => {}
}
}

match self {
PlanNode::Sequence { nodes } => {
value = parent_value.clone();
Expand Down Expand Up @@ -517,7 +501,22 @@ pub(crate) mod fetch {
)
.await
{
Some(variables) => variables,
Some(variables) => {
if variables.variables.is_empty() && !current_dir.is_empty() {
match data.pointer(&current_dir.to_string()) {
Some(matched_value) => {
if matched_value.is_null() {
return Ok((Value::from_path(current_dir, Value::Null), Vec::new()));
}
},
None => {
return Ok((Value::from_path(current_dir, Value::Null), Vec::new()));
}
}
}

variables
},
None => {
return Ok((Value::from_path(current_dir, Value::Null), Vec::new()));
}
Expand Down

0 comments on commit c228ce9

Please sign in to comment.