1
1
use std:: collections:: HashMap ;
2
2
3
- use super :: { AbstractTypeDefinitionExtension , TypeInfoRegistry } ;
3
+ use super :: { AbstractTypeDefinitionExtension , OperationVisitorContext , SchemaDocumentExtension } ;
4
4
use crate :: ast:: ext:: { SubTypeExtension , TypeDefinitionExtension } ;
5
5
use crate :: static_graphql:: {
6
6
query:: { self , Selection , TypeCondition } ,
7
7
schema:: { self , TypeDefinition } ,
8
8
} ;
9
- pub fn collect_fields (
9
+ pub fn collect_fields < ' a > (
10
10
selection_set : & query:: SelectionSet ,
11
11
parent_type : & schema:: TypeDefinition ,
12
12
known_fragments : & HashMap < String , query:: FragmentDefinition > ,
13
- type_info_registry : & TypeInfoRegistry ,
13
+ context : & ' a OperationVisitorContext < ' a > ,
14
14
) -> HashMap < String , Vec < query:: Field > > {
15
15
let mut map = HashMap :: new ( ) ;
16
16
let mut visited_fragments_names: Vec < String > = Vec :: new ( ) ;
@@ -19,7 +19,7 @@ pub fn collect_fields(
19
19
selection_set,
20
20
parent_type,
21
21
known_fragments,
22
- type_info_registry ,
22
+ context ,
23
23
& mut map,
24
24
& mut visited_fragments_names,
25
25
) ;
@@ -30,10 +30,10 @@ pub fn collect_fields(
30
30
fn does_fragment_condition_match < ' a > (
31
31
fragment_condition : & ' a Option < TypeCondition > ,
32
32
current_selection_set_type : & ' a TypeDefinition ,
33
- type_info_registry : & ' a TypeInfoRegistry < ' a > ,
33
+ context : & ' a OperationVisitorContext < ' a > ,
34
34
) -> bool {
35
35
if let Some ( TypeCondition :: On ( type_name) ) = fragment_condition {
36
- if let Some ( conditional_type) = type_info_registry . type_by_name . get ( type_name) {
36
+ if let Some ( conditional_type) = context . schema . type_by_name ( type_name) {
37
37
if conditional_type
38
38
. name ( )
39
39
. eq ( & current_selection_set_type. name ( ) )
@@ -60,11 +60,11 @@ fn does_fragment_condition_match<'a>(
60
60
}
61
61
}
62
62
63
- fn collect_fields_inner (
63
+ fn collect_fields_inner < ' a > (
64
64
selection_set : & query:: SelectionSet ,
65
65
parent_type : & schema:: TypeDefinition ,
66
66
known_fragments : & HashMap < String , query:: FragmentDefinition > ,
67
- type_info_registry : & TypeInfoRegistry ,
67
+ context : & ' a OperationVisitorContext < ' a > ,
68
68
result_arr : & mut HashMap < String , Vec < query:: Field > > ,
69
69
visited_fragments_names : & mut Vec < String > ,
70
70
) {
@@ -74,12 +74,12 @@ fn collect_fields_inner(
74
74
existing. push ( f. clone ( ) ) ;
75
75
}
76
76
Selection :: InlineFragment ( f) => {
77
- if does_fragment_condition_match ( & f. type_condition , parent_type, type_info_registry ) {
77
+ if does_fragment_condition_match ( & f. type_condition , parent_type, context ) {
78
78
collect_fields_inner (
79
79
& f. selection_set ,
80
80
& parent_type,
81
81
known_fragments,
82
- type_info_registry ,
82
+ context ,
83
83
result_arr,
84
84
visited_fragments_names,
85
85
) ;
@@ -97,13 +97,13 @@ fn collect_fields_inner(
97
97
if does_fragment_condition_match (
98
98
& Some ( fragment. type_condition . clone ( ) ) ,
99
99
& parent_type,
100
- type_info_registry ,
100
+ context ,
101
101
) {
102
102
collect_fields_inner (
103
103
& fragment. selection_set ,
104
104
& parent_type,
105
105
known_fragments,
106
- type_info_registry ,
106
+ context ,
107
107
result_arr,
108
108
visited_fragments_names,
109
109
) ;
0 commit comments