@@ -5,95 +5,95 @@ use serde_json::Result;
5
5
6
6
#[ derive( Serialize , Deserialize , Debug ) ]
7
7
pub struct IntrospectionQuery {
8
- __schema : IntrospectionSchema ,
8
+ pub __schema : IntrospectionSchema ,
9
9
}
10
10
11
11
#[ derive( Serialize , Deserialize , Debug ) ]
12
12
pub struct IntrospectionScalarType {
13
- name : String ,
14
- description : Option < String > ,
13
+ pub name : String ,
14
+ pub description : Option < String > ,
15
15
#[ serde( rename = "specifiedByURL" ) ]
16
- specified_by_url : Option < String > ,
16
+ pub specified_by_url : Option < String > ,
17
17
}
18
18
19
19
#[ derive( Serialize , Deserialize , Debug ) ]
20
20
pub struct IntrospectionInputValue {
21
- name : String ,
22
- description : Option < String > ,
21
+ pub name : String ,
22
+ pub description : Option < String > ,
23
23
#[ serde( rename = "defaultValue" ) ]
24
- default_value : Option < String > ,
24
+ pub default_value : Option < String > ,
25
25
#[ serde( rename = "isDeprecated" ) ]
26
- is_deprecated : Option < bool > ,
26
+ pub is_deprecated : Option < bool > ,
27
27
#[ serde( rename = "deprecationReason" ) ]
28
- deprecation_reason : Option < String > ,
28
+ pub deprecation_reason : Option < String > ,
29
29
#[ serde( rename = "type" ) ]
30
- type_ref : Option < IntrospectionInputTypeRef > ,
30
+ pub type_ref : Option < IntrospectionInputTypeRef > ,
31
31
}
32
32
33
33
#[ derive( Serialize , Deserialize , Debug ) ]
34
34
#[ serde( tag = "kind" ) ]
35
35
pub struct IntrospectionField {
36
- name : String ,
37
- description : Option < String > ,
38
- args : Vec < IntrospectionInputValue > ,
36
+ pub name : String ,
37
+ pub description : Option < String > ,
38
+ pub args : Vec < IntrospectionInputValue > ,
39
39
#[ serde( rename = "isDeprecated" ) ]
40
- is_deprecated : Option < bool > ,
40
+ pub is_deprecated : Option < bool > ,
41
41
#[ serde( rename = "deprecationReason" ) ]
42
- deprecation_reason : Option < String > ,
42
+ pub deprecation_reason : Option < String > ,
43
43
#[ serde( rename = "type" ) ]
44
- type_ref : IntrospectionOutputTypeRef ,
44
+ pub type_ref : IntrospectionOutputTypeRef ,
45
45
}
46
46
47
47
#[ derive( Serialize , Deserialize , Debug ) ]
48
48
pub struct IntrospectionObjectType {
49
- name : String ,
50
- description : Option < String > ,
51
- fields : Vec < IntrospectionField > ,
52
- interfaces : Vec < IntrospectionNamedTypeRef > ,
49
+ pub name : String ,
50
+ pub description : Option < String > ,
51
+ pub fields : Vec < IntrospectionField > ,
52
+ pub interfaces : Vec < IntrospectionNamedTypeRef > ,
53
53
}
54
54
55
55
#[ derive( Serialize , Deserialize , Debug ) ]
56
56
pub struct IntrospectionInterfaceType {
57
- name : String ,
58
- description : Option < String > ,
59
- fields : Vec < IntrospectionField > ,
60
- interfaces : Option < Vec < IntrospectionNamedTypeRef > > ,
57
+ pub name : String ,
58
+ pub description : Option < String > ,
59
+ pub fields : Vec < IntrospectionField > ,
60
+ pub interfaces : Option < Vec < IntrospectionNamedTypeRef > > ,
61
61
#[ serde( rename = "possibleTypes" ) ]
62
- possible_types : Vec < IntrospectionNamedTypeRef > ,
62
+ pub possible_types : Vec < IntrospectionNamedTypeRef > ,
63
63
}
64
64
65
65
#[ derive( Serialize , Deserialize , Debug ) ]
66
66
pub struct IntrospectionUnionType {
67
- name : String ,
68
- description : Option < String > ,
67
+ pub name : String ,
68
+ pub description : Option < String > ,
69
69
#[ serde( rename = "possibleTypes" ) ]
70
- possible_types : Vec < IntrospectionNamedTypeRef > ,
70
+ pub possible_types : Vec < IntrospectionNamedTypeRef > ,
71
71
}
72
72
73
73
#[ derive( Serialize , Deserialize , Debug ) ]
74
74
pub struct IntrospectionEnumValue {
75
- name : String ,
76
- description : Option < String > ,
75
+ pub name : String ,
76
+ pub description : Option < String > ,
77
77
#[ serde( rename = "isDeprecated" ) ]
78
- is_deprecated : Option < bool > ,
78
+ pub is_deprecated : Option < bool > ,
79
79
#[ serde( rename = "deprecationReason" ) ]
80
- deprecation_reason : Option < String > ,
80
+ pub deprecation_reason : Option < String > ,
81
81
}
82
82
83
83
#[ derive( Serialize , Deserialize , Debug ) ]
84
84
pub struct IntrospectionEnumType {
85
- name : String ,
86
- description : Option < String > ,
85
+ pub name : String ,
86
+ pub description : Option < String > ,
87
87
#[ serde( rename = "enumValues" ) ]
88
- enum_values : Vec < IntrospectionEnumValue > ,
88
+ pub enum_values : Vec < IntrospectionEnumValue > ,
89
89
}
90
90
91
91
#[ derive( Serialize , Deserialize , Debug ) ]
92
92
pub struct IntrospectionInputObjectType {
93
- name : String ,
94
- description : Option < String > ,
93
+ pub name : String ,
94
+ pub description : Option < String > ,
95
95
#[ serde( rename = "inputFields" ) ]
96
- input_fields : Vec < IntrospectionInputValue > ,
96
+ pub input_fields : Vec < IntrospectionInputValue > ,
97
97
}
98
98
99
99
#[ derive( Serialize , Deserialize , Debug ) ]
@@ -107,6 +107,19 @@ pub enum IntrospectionType {
107
107
INPUT_OBJECT ( IntrospectionInputObjectType ) ,
108
108
}
109
109
110
+ impl IntrospectionType {
111
+ pub fn name ( & self ) -> & String {
112
+ match & self {
113
+ IntrospectionType :: ENUM ( e) => & e. name ,
114
+ IntrospectionType :: OBJECT ( o) => & o. name ,
115
+ IntrospectionType :: INPUT_OBJECT ( io) => & io. name ,
116
+ IntrospectionType :: INTERFACE ( i) => & i. name ,
117
+ IntrospectionType :: SCALAR ( s) => & s. name ,
118
+ IntrospectionType :: UNION ( u) => & u. name ,
119
+ }
120
+ }
121
+ }
122
+
110
123
#[ derive( Serialize , Deserialize , Debug ) ]
111
124
#[ serde( tag = "kind" ) ]
112
125
pub enum IntrospectionInputType {
@@ -127,7 +140,7 @@ pub enum IntrospectionOutputType {
127
140
128
141
#[ derive( Serialize , Deserialize , Debug ) ]
129
142
pub struct IntrospectionNamedTypeRef {
130
- name : String ,
143
+ pub name : String ,
131
144
}
132
145
133
146
#[ derive( Serialize , Deserialize , Debug ) ]
@@ -167,15 +180,15 @@ pub enum IntrospectionInputTypeRef {
167
180
168
181
#[ derive( Serialize , Deserialize , Debug ) ]
169
182
pub struct IntrospectionSchema {
170
- description : Option < String > ,
183
+ pub description : Option < String > ,
171
184
#[ serde( rename = "queryType" ) ]
172
- query_type : IntrospectionNamedTypeRef ,
185
+ pub query_type : IntrospectionNamedTypeRef ,
173
186
#[ serde( rename = "mutationType" ) ]
174
- mutation_type : Option < IntrospectionNamedTypeRef > ,
187
+ pub mutation_type : Option < IntrospectionNamedTypeRef > ,
175
188
#[ serde( rename = "subscriptionType" ) ]
176
- subscription_type : Option < IntrospectionNamedTypeRef > ,
177
- types : Vec < IntrospectionType > ,
178
- directives : Vec < IntrospectionDirective > ,
189
+ pub subscription_type : Option < IntrospectionNamedTypeRef > ,
190
+ pub types : Vec < IntrospectionType > ,
191
+ pub directives : Vec < IntrospectionDirective > ,
179
192
}
180
193
181
194
#[ derive( Serialize , Deserialize , Debug ) ]
@@ -204,12 +217,12 @@ pub enum DirectiveLocation {
204
217
205
218
#[ derive( Serialize , Deserialize , Debug ) ]
206
219
pub struct IntrospectionDirective {
207
- name : String ,
208
- description : Option < String > ,
220
+ pub name : String ,
221
+ pub description : Option < String > ,
209
222
#[ serde( rename = "isRepeatable" ) ]
210
- is_repeatable : Option < bool > ,
211
- locations : Vec < DirectiveLocation > ,
212
- args : Vec < IntrospectionInputValue > ,
223
+ pub is_repeatable : Option < bool > ,
224
+ pub locations : Vec < DirectiveLocation > ,
225
+ pub args : Vec < IntrospectionInputValue > ,
213
226
}
214
227
215
228
pub fn parse_introspection < R > ( input : R ) -> Result < IntrospectionQuery >
0 commit comments