diff --git a/juniper/src/http/mod.rs b/juniper/src/http/mod.rs index dab4852d..a94c0e0c 100644 --- a/juniper/src/http/mod.rs +++ b/juniper/src/http/mod.rs @@ -33,6 +33,7 @@ impl GraphQLRequest 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) } diff --git a/juniper/test/graph_ql_request.rs b/juniper/test/graph_ql_request.rs new file mode 100644 index 00000000..89c7c8a5 --- /dev/null +++ b/juniper/test/graph_ql_request.rs @@ -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")); +}