1
1
use constants:: * ;
2
2
use failure;
3
- use heck:: SnakeCase ;
4
3
use proc_macro2:: { Ident , Span , TokenStream } ;
5
4
use query:: QueryContext ;
6
5
use selection:: { Selection , SelectionItem } ;
@@ -15,7 +14,7 @@ enum UnionError {
15
14
#[ fail( display = "Unknown type: {}" , ty) ]
16
15
UnknownType { ty : String } ,
17
16
#[ fail( display = "Missing __typename in selection for {}" , union_name) ]
18
- MissingTypename { union_name : String }
17
+ MissingTypename { union_name : String } ,
19
18
}
20
19
21
20
impl GqlUnion {
@@ -37,7 +36,9 @@ impl GqlUnion {
37
36
} ) ;
38
37
39
38
if typename_field. is_none ( ) {
40
- Err ( UnionError :: MissingTypename { union_name : prefix. into ( ) } ) ?;
39
+ Err ( UnionError :: MissingTypename {
40
+ union_name : prefix. into ( ) ,
41
+ } ) ?;
41
42
}
42
43
43
44
let variants: Result < Vec < TokenStream > , failure:: Error > = selection
@@ -53,7 +54,7 @@ impl GqlUnion {
53
54
} )
54
55
. map ( |item| {
55
56
match item {
56
- SelectionItem :: Field ( f ) => panic ! ( "field selection on union" ) ,
57
+ SelectionItem :: Field ( _ ) => panic ! ( "field selection on union" ) ,
57
58
SelectionItem :: FragmentSpread ( _) => panic ! ( "fragment spread on union" ) ,
58
59
SelectionItem :: InlineFragment ( frag) => {
59
60
let variant_name = Ident :: new ( & frag. on , Span :: call_site ( ) ) ;
@@ -63,23 +64,23 @@ impl GqlUnion {
63
64
let variant_type = Ident :: new ( & new_prefix, Span :: call_site ( ) ) ;
64
65
65
66
let field_object_type =
66
- query_context. schema . objects . get ( & frag. on ) . map ( |f | {
67
+ query_context. schema . objects . get ( & frag. on ) . map ( |_f | {
67
68
query_context. maybe_expand_field (
68
69
& frag. on ,
69
70
& frag. fields ,
70
71
& new_prefix,
71
72
)
72
73
} ) ;
73
74
let field_interface =
74
- query_context. schema . interfaces . get ( & frag. on ) . map ( |f | {
75
+ query_context. schema . interfaces . get ( & frag. on ) . map ( |_f | {
75
76
query_context. maybe_expand_field (
76
77
& frag. on ,
77
78
& frag. fields ,
78
79
& new_prefix,
79
80
)
80
81
} ) ;
81
82
// nested unions, is that even a thing?
82
- let field_union_type = query_context. schema . unions . get ( & frag. on ) . map ( |f | {
83
+ let field_union_type = query_context. schema . unions . get ( & frag. on ) . map ( |_f | {
83
84
query_context. maybe_expand_field ( & frag. on , & frag. fields , & new_prefix)
84
85
} ) ;
85
86
@@ -184,7 +185,10 @@ mod tests {
184
185
185
186
assert ! ( result. is_err( ) ) ;
186
187
187
- assert_eq ! ( format!( "{}" , result. unwrap_err( ) ) , "Missing __typename in selection for Meow" ) ;
188
+ assert_eq ! (
189
+ format!( "{}" , result. unwrap_err( ) ) ,
190
+ "Missing __typename in selection for Meow"
191
+ ) ;
188
192
}
189
193
190
194
#[ test]
@@ -196,21 +200,17 @@ mod tests {
196
200
} ) ,
197
201
SelectionItem :: InlineFragment ( SelectionInlineFragment {
198
202
on: "User" . to_string( ) ,
199
- fields: Selection ( vec![
200
- SelectionItem :: Field ( SelectionField {
201
- name: "first_name" . to_string( ) ,
202
- fields: Selection ( vec![ ] ) ,
203
- } ) ,
204
- ] ) ,
203
+ fields: Selection ( vec![ SelectionItem :: Field ( SelectionField {
204
+ name: "first_name" . to_string( ) ,
205
+ fields: Selection ( vec![ ] ) ,
206
+ } ) ] ) ,
205
207
} ) ,
206
208
SelectionItem :: InlineFragment ( SelectionInlineFragment {
207
209
on: "Organization" . to_string( ) ,
208
- fields: Selection ( vec![
209
- SelectionItem :: Field ( SelectionField {
210
- name: "title" . to_string( ) ,
211
- fields: Selection ( vec![ ] ) ,
212
- } ) ,
213
- ] ) ,
210
+ fields: Selection ( vec![ SelectionItem :: Field ( SelectionField {
211
+ name: "title" . to_string( ) ,
212
+ fields: Selection ( vec![ ] ) ,
213
+ } ) ] ) ,
214
214
} ) ,
215
215
] ;
216
216
let mut context = QueryContext :: new_empty ( ) ;
0 commit comments