Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions apollo-federation/src/query_plan/fetch_dependency_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2362,6 +2362,14 @@ impl FetchDependencyGraphNode {
.cloned()
.collect::<Vec<_>>()
};
let variable_usages = {
let mut list = variable_definitions
.iter()
.map(|var_def| var_def.name.clone())
.collect::<Vec<_>>();
list.sort();
list
};

let mut operation = if self.is_entity_fetch {
operation_for_entities_fetch(
Expand All @@ -2387,16 +2395,6 @@ impl FetchDependencyGraphNode {
operation.reuse_fragments(fragments)?;
}

let variable_usages = {
let mut list = operation
.variables
.iter()
.map(|variable| variable.name.clone())
.collect::<Vec<_>>();
list.sort();
list
};

let operation_document = operation.try_into()?;

let node = super::PlanNode::Fetch(Box::new(super::FetchNode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ fn test_if_directives_at_the_operation_level_are_passed_down_to_subgraph_queries
}
}
"#);
// This checks a regression where the `variable_usages` included the `representations` variable.
assert_eq!(b_fetch_nodes[0].variable_usages.len(), 0);
assert_eq!(b_fetch_nodes[1].variable_usages.len(), 0);
}

#[test]
Expand Down