File tree 2 files changed +9
-11
lines changed
2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 1
1
# master
2
2
3
- - Expose the operation name from ` GraphQLRequest ` .
3
+ - Expose the operation names from ` GraphQLRequest ` .
4
4
- Compatibility with the latest ` juniper ` .
5
5
6
6
# [ 0.2.0] 2018-12-17
Original file line number Diff line number Diff line change @@ -108,15 +108,11 @@ where
108
108
}
109
109
}
110
110
111
- pub fn operation_name ( & self ) -> Option < & str > {
111
+ pub fn operation_names ( & self ) -> Vec < Option < & str > > {
112
112
match self {
113
- GraphQLBatchRequest :: Single ( req) => req. operation_name ( ) ,
113
+ GraphQLBatchRequest :: Single ( req) => vec ! [ req. operation_name( ) ] ,
114
114
GraphQLBatchRequest :: Batch ( reqs) => {
115
- if reqs. len ( ) == 1 {
116
- reqs. get ( 0 ) . and_then ( |req| req. operation_name ( ) )
117
- } else {
118
- None
119
- }
115
+ reqs. iter ( ) . map ( |req| req. operation_name ( ) ) . collect ( )
120
116
}
121
117
}
122
118
}
@@ -187,9 +183,11 @@ where
187
183
GraphQLResponse ( status, json)
188
184
}
189
185
190
- /// Returns the `operation_name` associated with this request.
191
- pub fn operation_name ( & self ) -> Option < & str > {
192
- self . 0 . operation_name ( )
186
+ /// Returns the operation names associated with this request.
187
+ ///
188
+ /// For batch requests there will be multiple names.
189
+ pub fn operation_names ( & self ) -> Vec < Option < & str > > {
190
+ self . 0 . operation_names ( )
193
191
}
194
192
}
195
193
You can’t perform that action at this time.
0 commit comments