@@ -55,8 +55,10 @@ lazy_static! {
5555 CacheMap :: default ( ) ;
5656}
5757
58- pub struct GraphQLClientDeriveOptions < ' a > {
59- pub input : & ' a syn:: DeriveInput ,
58+ pub struct GraphQLClientDeriveOptions {
59+ pub selected_operation : String ,
60+ pub additional_derives : Option < String > ,
61+ pub deprecation_strategy : Option < deprecation:: DeprecationStrategy > ,
6062}
6163
6264#[ derive( Serialize , Deserialize , Debug ) ]
@@ -69,12 +71,13 @@ pub fn generate_module_token_stream(
6971 schema_path : std:: path:: PathBuf ,
7072 options : Option < GraphQLClientDeriveOptions > ,
7173) -> Result < TokenStream , failure:: Error > {
72- let input = options. unwrap ( ) . input ;
74+ let options = options. unwrap ( ) ;
7375
74- let response_derives = attributes :: extract_attr ( input , "response_derives" ) . ok ( ) ;
76+ let response_derives = options . additional_derives ;
7577
7678 // The user can determine what to do about deprecations.
77- let deprecation_strategy = deprecation:: extract_deprecation_strategy ( input)
79+ let deprecation_strategy = options
80+ . deprecation_strategy
7881 . unwrap_or ( deprecation:: DeprecationStrategy :: Warn ) ;
7982
8083 // We need to qualify the query with the path to the crate it is part of
@@ -122,13 +125,16 @@ pub fn generate_module_token_stream(
122125 }
123126 } ;
124127
125- let operation_string = input. ident . to_string ( ) ;
126- let module_name = Ident :: new ( & operation_string. to_snake_case ( ) , Span :: call_site ( ) ) ;
127- let struct_name = & input. ident ;
128+ let operation_string = options. selected_operation . clone ( ) ;
129+ let module_name = Ident :: new (
130+ options. selected_operation . to_snake_case ( ) . as_str ( ) ,
131+ Span :: call_site ( ) ,
132+ ) ;
133+ let struct_name = Ident :: new ( options. selected_operation . as_str ( ) , Span :: call_site ( ) ) ;
128134 let schema_output = codegen:: response_for_query (
129135 schema,
130136 query,
131- input . ident . to_string ( ) ,
137+ options . selected_operation . clone ( ) ,
132138 response_derives,
133139 deprecation_strategy,
134140 ) ?;
0 commit comments