@@ -55,8 +55,10 @@ lazy_static! {
55
55
CacheMap :: default ( ) ;
56
56
}
57
57
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 > ,
60
62
}
61
63
62
64
#[ derive( Serialize , Deserialize , Debug ) ]
@@ -69,12 +71,13 @@ pub fn generate_module_token_stream(
69
71
schema_path : std:: path:: PathBuf ,
70
72
options : Option < GraphQLClientDeriveOptions > ,
71
73
) -> Result < TokenStream , failure:: Error > {
72
- let input = options. unwrap ( ) . input ;
74
+ let options = options. unwrap ( ) ;
73
75
74
- let response_derives = attributes :: extract_attr ( input , "response_derives" ) . ok ( ) ;
76
+ let response_derives = options . additional_derives ;
75
77
76
78
// 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
78
81
. unwrap_or ( deprecation:: DeprecationStrategy :: Warn ) ;
79
82
80
83
// 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(
122
125
}
123
126
} ;
124
127
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 ( ) ) ;
128
134
let schema_output = codegen:: response_for_query (
129
135
schema,
130
136
query,
131
- input . ident . to_string ( ) ,
137
+ options . selected_operation . clone ( ) ,
132
138
response_derives,
133
139
deprecation_strategy,
134
140
) ?;
0 commit comments