@@ -5,7 +5,7 @@ use crate::ast::type_aware_selection::TypeAwareSelection;
55use crate :: graph:: edge:: { Edge , FieldMove , InterfaceObjectTypeMove , PlannerOverrideContext } ;
66use crate :: graph:: node:: Node ;
77use crate :: graph:: Graph ;
8- use crate :: planner:: fetch:: fetch_step_data:: { FetchStepData , FetchStepKind } ;
8+ use crate :: planner:: fetch:: fetch_step_data:: { FetchStepData , FetchStepFlags , FetchStepKind } ;
99use crate :: planner:: plan_nodes:: { FetchNodePathSegment , FetchRewrite , ValueSetter } ;
1010use crate :: planner:: tree:: query_tree:: QueryTree ;
1111use crate :: planner:: tree:: query_tree_node:: { MutationFieldPosition , QueryTreeNode } ;
@@ -236,6 +236,11 @@ impl Display for FetchGraph {
236236}
237237
238238fn create_noop_fetch_step ( fetch_graph : & mut FetchGraph , created_from_requires : bool ) -> NodeIndex {
239+ let flags = if created_from_requires {
240+ FetchStepFlags :: USED_FOR_REQUIRES
241+ } else {
242+ FetchStepFlags :: empty ( )
243+ } ;
239244 fetch_graph. add_step ( FetchStepData {
240245 service_name : SubgraphName :: any ( ) ,
241246 response_path : MergePath :: default ( ) ,
@@ -247,7 +252,7 @@ fn create_noop_fetch_step(fetch_graph: &mut FetchGraph, created_from_requires: b
247252 selection_set : SelectionSet :: default ( ) ,
248253 type_name : "*" . to_string ( ) ,
249254 } ,
250- used_for_requires : created_from_requires ,
255+ flags ,
251256 condition : None ,
252257 kind : FetchStepKind :: Root ,
253258 input_rewrites : None ,
@@ -268,6 +273,11 @@ fn create_fetch_step_for_entity_call(
268273 condition : Option < & Condition > ,
269274 used_for_requires : bool ,
270275) -> NodeIndex {
276+ let flags = if used_for_requires {
277+ FetchStepFlags :: USED_FOR_REQUIRES
278+ } else {
279+ FetchStepFlags :: empty ( )
280+ } ;
271281 fetch_graph. add_step ( FetchStepData {
272282 service_name : subgraph_name. clone ( ) ,
273283 response_path : response_path. clone ( ) ,
@@ -281,7 +291,7 @@ fn create_fetch_step_for_entity_call(
281291 selection_set : SelectionSet :: default ( ) ,
282292 type_name : output_type_name. to_string ( ) ,
283293 } ,
284- used_for_requires ,
294+ flags ,
285295 condition : condition. cloned ( ) ,
286296 kind : FetchStepKind :: Entity ,
287297 input_rewrites : None ,
@@ -311,7 +321,7 @@ fn create_fetch_step_for_root_move(
311321 selection_set : SelectionSet :: default ( ) ,
312322 type_name : type_name. to_string ( ) ,
313323 } ,
314- used_for_requires : false ,
324+ flags : FetchStepFlags :: empty ( ) ,
315325 condition : None ,
316326 kind : FetchStepKind :: Root ,
317327 variable_usages : None ,
@@ -373,7 +383,9 @@ fn ensure_fetch_step_for_subgraph(
373383
374384 // If there are requirements, then we do not re-use
375385 // optimizations will try to re-use the existing step later, if possible.
376- if fetch_step. used_for_requires || requires. is_some ( ) {
386+ if fetch_step. flags . contains ( FetchStepFlags :: USED_FOR_REQUIRES )
387+ || requires. is_some ( )
388+ {
377389 return None ;
378390 }
379391
@@ -713,13 +725,18 @@ fn process_entity_move_edge(
713725 output_type_name,
714726 fetch_step_index. index( )
715727 ) ;
728+
716729 fetch_step. add_input_rewrite ( FetchRewrite :: ValueSetter ( ValueSetter {
717730 path : vec ! [
718731 FetchNodePathSegment :: TypenameEquals ( output_type_name. to_string( ) ) ,
719732 FetchNodePathSegment :: Key ( "__typename" . to_string( ) ) ,
720733 ] ,
721734 set_value_to : output_type_name. clone ( ) . into ( ) ,
722735 } ) ) ;
736+
737+ fetch_step
738+ . flags
739+ . insert ( FetchStepFlags :: USED_FOR_TYPE_CONDITION ) ;
723740 }
724741
725742 let parent_fetch_step = fetch_graph. get_step_data_mut ( parent_fetch_step_index) ?;
0 commit comments