@@ -7,8 +7,8 @@ use crate::{
77 merge_path:: { MergePath , Segment } ,
88 selection_item:: SelectionItem ,
99 selection_set:: { FieldSelection , SelectionSet } ,
10- type_aware_selection:: TypeAwareSelection ,
1110 } ,
11+ planner:: fetch:: { selections:: FetchStepSelections , state:: MultiTypeFetchStep } ,
1212 state:: {
1313 subgraph_state:: { SubgraphDefinition , SubgraphState } ,
1414 supergraph_state:: { SubgraphName , SupergraphState , TypeNode } ,
@@ -20,46 +20,43 @@ pub struct SelectionMismatchFinder<'a> {
2020 supergraph_state : & ' a SupergraphState ,
2121}
2222
23- type MismatchesFound = Vec < MergePath > ;
23+ type MismatchesFound = Vec < ( String , MergePath ) > ;
2424
2525impl < ' a > SelectionMismatchFinder < ' a > {
2626 pub fn new ( supergraph_state : & ' a SupergraphState ) -> Self {
2727 Self { supergraph_state }
2828 }
2929
30- #[ instrument( level = "trace" , skip_all, fields(
31- subgraph_name,
32- selection = format!( "{}" , selection_set)
33- ) ) ]
30+ #[ instrument( level = "trace" , skip_all, fields( subgraph_name, ) ) ]
3431 pub fn find_mismatches_in_node (
3532 & self ,
3633 subgraph_name : & SubgraphName ,
37- selection_set : & TypeAwareSelection ,
34+ selections : & FetchStepSelections < MultiTypeFetchStep > ,
3835 ) -> MismatchesFound {
39- let subgraph_state = self
40- . supergraph_state
41- . subgraphs_state
42- . get ( subgraph_name)
43- . unwrap ( ) ;
44-
45- let entrypoint_type = subgraph_state
46- . definitions
47- . get ( & selection_set. type_name )
48- . unwrap ( ) ;
49-
5036 let mut mismtaches_found = MismatchesFound :: new ( ) ;
51- let start_path = MergePath :: default ( ) ;
5237
53- handle_selection_set (
54- self . supergraph_state ,
55- subgraph_state,
56- entrypoint_type,
57- & selection_set. selection_set ,
58- start_path,
59- & mut mismtaches_found,
60- ) ;
61-
62- trace ! ( "found total of {} mismatches" , mismtaches_found. len( ) , ) ;
38+ for ( definition_name, selection_set) in selections. iter_selections ( ) {
39+ let subgraph_state = self
40+ . supergraph_state
41+ . subgraphs_state
42+ . get ( subgraph_name)
43+ . unwrap ( ) ;
44+
45+ let entrypoint_type = subgraph_state. definitions . get ( definition_name) . unwrap ( ) ;
46+ let start_path = MergePath :: default ( ) ;
47+
48+ handle_selection_set (
49+ definition_name,
50+ self . supergraph_state ,
51+ subgraph_state,
52+ entrypoint_type,
53+ selection_set,
54+ start_path,
55+ & mut mismtaches_found,
56+ ) ;
57+
58+ trace ! ( "found total of {} mismatches" , mismtaches_found. len( ) ) ;
59+ }
6360
6461 mismtaches_found
6562 }
@@ -73,6 +70,7 @@ impl<'a> SelectionMismatchFinder<'a> {
7370 selection = format!( "{}" , selection_set)
7471) ) ]
7572fn handle_selection_set < ' field , ' schema > (
73+ root_def_type_name : & str ,
7674 supergraph_state : & ' schema SupergraphState ,
7775 subgraph_state : & ' schema SubgraphState ,
7876 parent_def : & ' schema SubgraphDefinition ,
@@ -105,6 +103,7 @@ fn handle_selection_set<'field, 'schema>(
105103 ) ) ;
106104
107105 let next_parent_type_name = handle_field (
106+ root_def_type_name,
108107 supergraph_state,
109108 type_def,
110109 field,
@@ -117,6 +116,7 @@ fn handle_selection_set<'field, 'schema>(
117116 next_parent_type_name. and_then ( |n| subgraph_state. definitions . get ( n) )
118117 {
119118 handle_selection_set (
119+ root_def_type_name,
120120 supergraph_state,
121121 subgraph_state,
122122 next_parent_def,
@@ -156,6 +156,7 @@ fn handle_selection_set<'field, 'schema>(
156156///
157157/// Returns the return type of the selection, if the inner selection needs to be processed (in case nested selections are defined).
158158fn handle_field < ' field , ' schema > (
159+ root_def_type_name : & str ,
159160 state : & ' schema SupergraphState ,
160161 parent_def : & ' schema SubgraphDefinition ,
161162 field : & ' field FieldSelection ,
@@ -201,7 +202,7 @@ fn handle_field<'field, 'schema>(
201202 field_path,
202203 ) ;
203204
204- mismatches_found. push ( field_path. clone ( ) ) ;
205+ mismatches_found. push ( ( root_def_type_name . to_string ( ) , field_path. clone ( ) ) ) ;
205206 }
206207 }
207208 } else {
0 commit comments