File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
graphql_client_codegen/src Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ fn introspect_schema(
78
78
let request_body: graphql_client:: GraphQLQueryBody < ( ) > = graphql_client:: GraphQLQueryBody {
79
79
variables : ( ) ,
80
80
query : introspection_query:: QUERY ,
81
+ operation_name : introspection_query:: OPERATION_NAME ,
81
82
} ;
82
83
83
84
let headers = set_headers ( authorization) ;
Original file line number Diff line number Diff line change @@ -122,7 +122,8 @@ pub fn generate_module_token_stream(
122
122
}
123
123
} ;
124
124
125
- let module_name = Ident :: new ( & input. ident . to_string ( ) . to_snake_case ( ) , Span :: call_site ( ) ) ;
125
+ let operation_string = input. ident . to_string ( ) ;
126
+ let module_name = Ident :: new ( & operation_string. to_snake_case ( ) , Span :: call_site ( ) ) ;
126
127
let struct_name = & input. ident ;
127
128
let schema_output = codegen:: response_for_query (
128
129
schema,
@@ -141,6 +142,7 @@ pub fn generate_module_token_stream(
141
142
use serde;
142
143
143
144
pub const QUERY : & ' static str = #query_string;
145
+ pub const OPERATION_NAME : & ' static str = #operation_string;
144
146
145
147
#schema_output
146
148
}
@@ -153,6 +155,7 @@ pub fn generate_module_token_stream(
153
155
:: graphql_client:: GraphQLQueryBody {
154
156
variables,
155
157
query: #module_name:: QUERY ,
158
+ operation_name: #module_name:: OPERATION_NAME ,
156
159
}
157
160
158
161
}
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ use std::collections::HashMap;
49
49
/// };
50
50
///
51
51
/// let expected_body = json!({
52
+ /// "operationName": star_wars_query::OPERATION_NAME,
52
53
/// "query": star_wars_query::QUERY,
53
54
/// "variables": {
54
55
/// "episodeForHero": "NEWHOPE"
84
85
pub variables : Variables ,
85
86
/// The GraphQL query, as a string.
86
87
pub query : & ' static str ,
88
+ /// The GraphQL operation name, as a string.
89
+ #[ serde( rename = "operationName" ) ]
90
+ pub operation_name : & ' static str ,
87
91
}
88
92
89
93
/// Represents a location inside a query string. Used in errors. See [`GraphQLError`].
You can’t perform that action at this time.
0 commit comments