11use failure;
22use field_type:: FieldType ;
3- use graphql_parser:: query;
43use heck:: { CamelCase , SnakeCase } ;
54use proc_macro2:: { Ident , Span , TokenStream } ;
65use query:: QueryContext ;
76use shared:: render_object_field;
7+ use selection:: * ;
88
99#[ derive( Debug , PartialEq ) ]
1010pub struct GqlObject {
@@ -22,7 +22,7 @@ impl GqlObject {
2222 pub fn response_for_selection (
2323 & self ,
2424 query_context : & QueryContext ,
25- selection : & query :: SelectionSet ,
25+ selection : & Selection ,
2626 prefix : & str ,
2727 ) -> Result < TokenStream , failure:: Error > {
2828 let name = Ident :: new ( prefix, Span :: call_site ( ) ) ;
@@ -41,14 +41,14 @@ impl GqlObject {
4141 pub fn field_impls_for_selection (
4242 & self ,
4343 query_context : & QueryContext ,
44- selection : & query :: SelectionSet ,
44+ selection : & Selection ,
4545 prefix : & str ,
4646 ) -> Result < Vec < TokenStream > , failure:: Error > {
4747 selection
48- . items
48+ . 0
4949 . iter ( )
5050 . map ( |selected| {
51- if let query :: Selection :: Field ( selected) = selected {
51+ if let SelectionItem :: Field ( selected) = selected {
5252 let ty = self
5353 . fields
5454 . iter ( )
@@ -61,7 +61,7 @@ impl GqlObject {
6161 prefix. to_camel_case( ) ,
6262 selected. name. to_camel_case( )
6363 ) ;
64- query_context. maybe_expand_field ( & selected , & ty , & prefix)
64+ query_context. maybe_expand_field ( & ty , & selected . fields , & prefix)
6565 } else {
6666 Ok ( quote ! ( ) )
6767 }
@@ -72,14 +72,14 @@ impl GqlObject {
7272 pub fn response_fields_for_selection (
7373 & self ,
7474 query_context : & QueryContext ,
75- selection : & query :: SelectionSet ,
75+ selection : & Selection ,
7676 prefix : & str ,
7777 ) -> Vec < TokenStream > {
7878 let mut fields = Vec :: new ( ) ;
7979
80- for item in selection. items . iter ( ) {
80+ for item in selection. 0 . iter ( ) {
8181 match item {
82- query :: Selection :: Field ( f) => {
82+ SelectionItem :: Field ( f) => {
8383 let name = & f. name ;
8484 let ty = & self
8585 . fields
@@ -93,7 +93,7 @@ impl GqlObject {
9393 ) ;
9494 fields. push ( render_object_field ( name, ty) ) ;
9595 }
96- query :: Selection :: FragmentSpread ( fragment) => {
96+ SelectionItem :: FragmentSpread ( fragment) => {
9797 let field_name =
9898 Ident :: new ( & fragment. fragment_name . to_snake_case ( ) , Span :: call_site ( ) ) ;
9999 let type_name = Ident :: new ( & fragment. fragment_name , Span :: call_site ( ) ) ;
@@ -102,7 +102,7 @@ impl GqlObject {
102102 #field_name: #type_name
103103 } )
104104 }
105- query :: Selection :: InlineFragment ( _) => {
105+ SelectionItem :: InlineFragment ( _) => {
106106 unreachable ! ( "inline fragment on object field" )
107107 }
108108 }
0 commit comments