1#![allow(non_camel_case_types)]
2
3use serde::{Deserialize, Deserializer, Serialize};
4
5#[derive(Clone, Debug)]
6pub enum __DirectiveLocation {
7 QUERY,
8 MUTATION,
9 SUBSCRIPTION,
10 FIELD,
11 FRAGMENT_DEFINITION,
12 FRAGMENT_SPREAD,
13 INLINE_FRAGMENT,
14 SCHEMA,
15 SCALAR,
16 OBJECT,
17 FIELD_DEFINITION,
18 ARGUMENT_DEFINITION,
19 INTERFACE,
20 UNION,
21 ENUM,
22 ENUM_VALUE,
23 INPUT_OBJECT,
24 INPUT_FIELD_DEFINITION,
25 Other(String),
26}
27
28impl Serialize for __DirectiveLocation {
29 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
30 ser.serialize_str(match *self {
31 __DirectiveLocation::QUERY => "QUERY",
32 __DirectiveLocation::MUTATION => "MUTATION",
33 __DirectiveLocation::SUBSCRIPTION => "SUBSCRIPTION",
34 __DirectiveLocation::FIELD => "FIELD",
35 __DirectiveLocation::FRAGMENT_DEFINITION => "FRAGMENT_DEFINITION",
36 __DirectiveLocation::FRAGMENT_SPREAD => "FRAGMENT_SPREAD",
37 __DirectiveLocation::INLINE_FRAGMENT => "INLINE_FRAGMENT",
38 __DirectiveLocation::SCHEMA => "SCHEMA",
39 __DirectiveLocation::SCALAR => "SCALAR",
40 __DirectiveLocation::OBJECT => "OBJECT",
41 __DirectiveLocation::FIELD_DEFINITION => "FIELD_DEFINITION",
42 __DirectiveLocation::ARGUMENT_DEFINITION => "ARGUMENT_DEFINITION",
43 __DirectiveLocation::INTERFACE => "INTERFACE",
44 __DirectiveLocation::UNION => "UNION",
45 __DirectiveLocation::ENUM => "ENUM",
46 __DirectiveLocation::ENUM_VALUE => "ENUM_VALUE",
47 __DirectiveLocation::INPUT_OBJECT => "INPUT_OBJECT",
48 __DirectiveLocation::INPUT_FIELD_DEFINITION => "INPUT_FIELD_DEFINITION",
49 __DirectiveLocation::Other(ref s) => s.as_str(),
50 })
51 }
52}
53
54impl<'de> Deserialize<'de> for __DirectiveLocation {
55 fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
56 let s = <&'de str>::deserialize(deserializer)?;
57 match s {
58 "QUERY" => Ok(__DirectiveLocation::QUERY),
59 "MUTATION" => Ok(__DirectiveLocation::MUTATION),
60 "SUBSCRIPTION" => Ok(__DirectiveLocation::SUBSCRIPTION),
61 "FIELD" => Ok(__DirectiveLocation::FIELD),
62 "FRAGMENT_DEFINITION" => Ok(__DirectiveLocation::FRAGMENT_DEFINITION),
63 "FRAGMENT_SPREAD" => Ok(__DirectiveLocation::FRAGMENT_SPREAD),
64 "INLINE_FRAGMENT" => Ok(__DirectiveLocation::INLINE_FRAGMENT),
65 "SCHEMA" => Ok(__DirectiveLocation::SCHEMA),
66 "SCALAR" => Ok(__DirectiveLocation::SCALAR),
67 "OBJECT" => Ok(__DirectiveLocation::OBJECT),
68 "FIELD_DEFINITION" => Ok(__DirectiveLocation::FIELD_DEFINITION),
69 "ARGUMENT_DEFINITION" => Ok(__DirectiveLocation::ARGUMENT_DEFINITION),
70 "INTERFACE" => Ok(__DirectiveLocation::INTERFACE),
71 "UNION" => Ok(__DirectiveLocation::UNION),
72 "ENUM" => Ok(__DirectiveLocation::ENUM),
73 "ENUM_VALUE" => Ok(__DirectiveLocation::ENUM_VALUE),
74 "INPUT_OBJECT" => Ok(__DirectiveLocation::INPUT_OBJECT),
75 "INPUT_FIELD_DEFINITION" => Ok(__DirectiveLocation::INPUT_FIELD_DEFINITION),
76 _ => Ok(__DirectiveLocation::Other(s.to_string())),
77 }
78 }
79}
80
81#[derive(Clone, Debug, PartialEq)]
82pub enum __TypeKind {
83 SCALAR,
84 OBJECT,
85 INTERFACE,
86 UNION,
87 ENUM,
88 INPUT_OBJECT,
89 LIST,
90 NON_NULL,
91 Other(String),
92}
93
94impl Serialize for __TypeKind {
95 fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
96 ser.serialize_str(match *self {
97 __TypeKind::SCALAR => "SCALAR",
98 __TypeKind::OBJECT => "OBJECT",
99 __TypeKind::INTERFACE => "INTERFACE",
100 __TypeKind::UNION => "UNION",
101 __TypeKind::ENUM => "ENUM",
102 __TypeKind::INPUT_OBJECT => "INPUT_OBJECT",
103 __TypeKind::LIST => "LIST",
104 __TypeKind::NON_NULL => "NON_NULL",
105 __TypeKind::Other(ref s) => s.as_str(),
106 })
107 }
108}
109
110impl<'de> Deserialize<'de> for __TypeKind {
111 fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
112 let s = <&'de str>::deserialize(deserializer)?;
113 match s {
114 "SCALAR" => Ok(__TypeKind::SCALAR),
115 "OBJECT" => Ok(__TypeKind::OBJECT),
116 "INTERFACE" => Ok(__TypeKind::INTERFACE),
117 "UNION" => Ok(__TypeKind::UNION),
118 "ENUM" => Ok(__TypeKind::ENUM),
119 "INPUT_OBJECT" => Ok(__TypeKind::INPUT_OBJECT),
120 "LIST" => Ok(__TypeKind::LIST),
121 "NON_NULL" => Ok(__TypeKind::NON_NULL),
122 _ => Ok(__TypeKind::Other(s.to_string())),
123 }
124 }
125}
126
127#[derive(Clone, Debug, Deserialize)]
128#[serde(rename_all = "camelCase")]
129pub struct FullType {
130 pub kind: Option<__TypeKind>,
131 pub name: Option<String>,
132 pub description: Option<String>,
133 pub fields: Option<Vec<FullTypeFields>>,
134 pub input_fields: Option<Vec<FullTypeInputFields>>,
135 pub interfaces: Option<Vec<FullTypeInterfaces>>,
136 pub enum_values: Option<Vec<FullTypeEnumValues>>,
137 pub possible_types: Option<Vec<FullTypePossibleTypes>>,
138}
139
140#[derive(Clone, Debug, Deserialize)]
141#[serde(rename_all = "camelCase")]
142pub struct FullTypeFieldsArgs {
143 #[serde(flatten)]
144 input_value: InputValue,
145}
146
147#[derive(Clone, Debug, Deserialize)]
148#[serde(rename_all = "camelCase")]
149pub struct FullTypeFieldsType {
150 #[serde(flatten)]
151 pub type_ref: TypeRef,
152}
153
154#[derive(Clone, Debug, Deserialize)]
155#[serde(rename_all = "camelCase")]
156pub struct FullTypeFields {
157 pub name: Option<String>,
158 pub description: Option<String>,
159 pub args: Option<Vec<Option<FullTypeFieldsArgs>>>,
160 #[serde(rename = "type")]
161 pub type_: Option<FullTypeFieldsType>,
162 pub is_deprecated: Option<bool>,
163 pub deprecation_reason: Option<String>,
164}
165
166#[derive(Clone, Debug, Deserialize)]
167#[serde(rename_all = "camelCase")]
168pub struct FullTypeInputFields {
169 #[serde(flatten)]
170 pub input_value: InputValue,
171}
172
173#[derive(Clone, Debug, Deserialize)]
174#[serde(rename_all = "camelCase")]
175pub struct FullTypeInterfaces {
176 #[serde(flatten)]
177 pub type_ref: TypeRef,
178}
179
180#[derive(Clone, Debug, Deserialize)]
181#[serde(rename_all = "camelCase")]
182pub struct FullTypeEnumValues {
183 pub name: Option<String>,
184 pub description: Option<String>,
185 pub is_deprecated: Option<bool>,
186 pub deprecation_reason: Option<String>,
187}
188
189#[derive(Clone, Debug, Deserialize)]
190#[serde(rename_all = "camelCase")]
191pub struct FullTypePossibleTypes {
192 #[serde(flatten)]
193 pub type_ref: TypeRef,
194}
195
196#[derive(Clone, Debug, Deserialize)]
197#[serde(rename_all = "camelCase")]
198pub struct InputValue {
199 pub name: String,
200 pub description: Option<String>,
201 #[serde(rename = "type")]
202 pub type_: InputValueType,
203 pub default_value: Option<String>,
204}
205
206type InputValueType = TypeRef;
207
208#[derive(Clone, Debug, Deserialize)]
209#[serde(rename_all = "camelCase")]
210pub struct TypeRef {
211 pub kind: Option<__TypeKind>,
212 pub name: Option<String>,
213 pub of_type: Option<Box<TypeRef>>,
214}
215
216#[derive(Clone, Debug, Deserialize)]
217#[serde(rename_all = "camelCase")]
218pub struct SchemaQueryType {
219 pub name: Option<String>,
220}
221
222#[derive(Clone, Debug, Deserialize)]
223#[serde(rename_all = "camelCase")]
224pub struct SchemaMutationType {
225 pub name: Option<String>,
226}
227
228#[derive(Clone, Debug, Deserialize)]
229#[serde(rename_all = "camelCase")]
230pub struct SchemaSubscriptionType {
231 pub name: Option<String>,
232}
233
234#[derive(Clone, Debug, Deserialize)]
235#[serde(rename_all = "camelCase")]
236pub struct SchemaTypes {
237 #[serde(flatten)]
238 pub full_type: FullType,
239}
240
241#[derive(Clone, Debug, Deserialize)]
242#[serde(rename_all = "camelCase")]
243pub struct SchemaDirectivesArgs {
244 #[serde(flatten)]
245 input_value: InputValue,
246}
247
248#[derive(Clone, Debug, Deserialize)]
249#[serde(rename_all = "camelCase")]
250pub struct SchemaDirectives {
251 pub name: Option<String>,
252 pub description: Option<String>,
253 pub locations: Option<Vec<Option<__DirectiveLocation>>>,
254 pub args: Option<Vec<Option<SchemaDirectivesArgs>>>,
255}
256
257#[derive(Clone, Debug, Deserialize)]
258#[serde(rename_all = "camelCase")]
259pub struct Schema {
260 pub query_type: Option<SchemaQueryType>,
261 pub mutation_type: Option<SchemaMutationType>,
262 pub subscription_type: Option<SchemaSubscriptionType>,
263 pub types: Option<Vec<Option<SchemaTypes>>>,
264 directives: Option<Vec<Option<SchemaDirectives>>>,
265}
266
267#[derive(Clone, Debug, Deserialize)]
268pub struct SchemaContainer {
269 #[serde(rename = "__schema")]
270 pub schema: Option<Schema>,
271}
272
273#[derive(Deserialize, Debug)]
274pub struct FullResponse<T> {
275 data: T,
276}
277
278#[derive(Debug, Deserialize)]
279#[serde(untagged)]
280pub enum IntrospectionResponse {
281 FullResponse(FullResponse<SchemaContainer>),
282 Schema(SchemaContainer),
283}
284
285impl IntrospectionResponse {
286 pub fn as_schema(&self) -> &SchemaContainer {
287 match self {
288 IntrospectionResponse::FullResponse(full_response) => &full_response.data,
289 IntrospectionResponse::Schema(schema) => schema,
290 }
291 }
292
293 pub fn into_schema(self) -> SchemaContainer {
294 match self {
295 IntrospectionResponse::FullResponse(full_response) => full_response.data,
296 IntrospectionResponse::Schema(schema) => schema,
297 }
298 }
299}