Skip to content

Commit 22faccf

Browse files
tnineslingclaude
andcommitted
refactor(incremental): add FetchNode::new() constructor
Reduces boilerplate at the three FetchNode construction sites. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c657a20 commit 22faccf

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

  • apollo-federation/src/query_plan/incremental_planner/fetch_graph

‎apollo-federation/src/query_plan/incremental_planner/fetch_graph/mod.rs‎

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ pub(crate) struct FetchNode {
6868
}
6969

7070
impl FetchNode {
71+
pub(crate) fn new(subgraph: Arc<str>, kind: FetchGroupKind) -> Self {
72+
Self {
73+
subgraph,
74+
kind,
75+
selection_builder: SelectionBuilder::default(),
76+
}
77+
}
78+
7179
/// Get the root type if this is a root fetch group.
7280
pub(crate) fn root_type(&self) -> Option<&CompositeTypeDefinitionPosition> {
7381
match &self.kind {
@@ -287,11 +295,7 @@ impl FetchGraph {
287295
return id;
288296
}
289297
self.insert_node(
290-
FetchNode {
291-
subgraph: subgraph.clone(),
292-
kind: FetchGroupKind::Root { root_type },
293-
selection_builder: SelectionBuilder::default(),
294-
},
298+
FetchNode::new(subgraph.clone(), FetchGroupKind::Root { root_type }),
295299
Some(subgraph.clone()),
296300
)
297301
}
@@ -303,11 +307,7 @@ impl FetchGraph {
303307
merge_at: Vec<FetchDataPathElement>,
304308
) -> NodeIndex {
305309
self.insert_node(
306-
FetchNode {
307-
subgraph: subgraph.clone(),
308-
kind: FetchGroupKind::Entity { merge_at },
309-
selection_builder: SelectionBuilder::default(),
310-
},
310+
FetchNode::new(subgraph.clone(), FetchGroupKind::Entity { merge_at }),
311311
None,
312312
)
313313
}
@@ -319,14 +319,13 @@ impl FetchGraph {
319319
merge_at: Vec<FetchDataPathElement>,
320320
) -> NodeIndex {
321321
self.insert_node(
322-
FetchNode {
323-
subgraph: subgraph.clone(),
324-
kind: FetchGroupKind::RootHop {
322+
FetchNode::new(
323+
subgraph.clone(),
324+
FetchGroupKind::RootHop {
325325
root_type,
326326
merge_at,
327327
},
328-
selection_builder: SelectionBuilder::default(),
329-
},
328+
),
330329
None,
331330
)
332331
}

0 commit comments

Comments
 (0)