Make operation_name public (#265)

Fixes #253.
This commit is contained in:
Cole Graber-Mitchell 2018-10-23 08:09:39 -04:00 committed by Christian Legnitto
parent edecb8c99f
commit cf7e8df65f
2 changed files with 11 additions and 0 deletions

View file

@ -33,6 +33,7 @@ impl<S> GraphQLRequest<S>
where
S: ScalarValue,
{
/// Returns the `operation_name` associated with this request.
fn operation_name(&self) -> Option<&str> {
self.operation_name.as_ref().map(|oper_name| &**oper_name)
}

View file

@ -0,0 +1,10 @@
extern crate juniper;
#[test]
fn pub_operation_name() {
use juniper::http::GraphQLRequest;
let request = GraphQLRequest::new("query".to_string(), Some("name".to_string()), None);
assert_eq!(request.operation_name(), Some("name"));
}