Repository: graphql-rust/juniper (language: rust)

Issue:
Consider making inner GraphQLRequest public or implement Display
Hello team,

We're using `juniper_rocket_async` and it all works great, but I can't find a way of accessing the inner graphql request object. I would like to log it, either as just a string or as json.

 
Specifically, it would be convenient if this inner type was public https://github.com/graphql-rust/juniper/blob/9c9639e8f0da0337880759c6fde469f863f74841/juniper_rocket_async/src/lib.rs#L64

However, that maybe is an API change you're not very interested in. Any ideas for a better solution? I would be happy to provide a PR.

Best,
Knut


Discussion / hints:
I think either route is reasonable!
@knutin would be `AsRef` + `AsMut` enough for your purposes?
@tyranron Yes, `AsRef` would be perfect!

Fix patch:
diff --git a/juniper_rocket/CHANGELOG.md b/juniper_rocket/CHANGELOG.md
index 7f0e099d8..9d047ea4d 100644
--- a/juniper_rocket/CHANGELOG.md
+++ b/juniper_rocket/CHANGELOG.md
@@ -1,6 +1,7 @@
 # master
 
 - Compatibility with the latest `juniper`.
+- Provide `AsRef` and `AsMut` implementation for `GraphQLRequest` to its inner type ([#968](https://github.com/graphql-rust/juniper/pull/968), [#930](https://github.com/graphql-rust/juniper/issues/930)).
 
 # [[0.8.0] 2021-07-08](https://github.com/graphql-rust/juniper/releases/tag/juniper_rocket-0.8.0)
 
diff --git a/juniper_rocket/src/lib.rs b/juniper_rocket/src/lib.rs
index 2ab7898d8..9d644c9f8 100644
--- a/juniper_rocket/src/lib.rs
+++ b/juniper_rocket/src/lib.rs
@@ -65,6 +65,18 @@ pub struct GraphQLRequest<S = DefaultScalarValue>(GraphQLBatchRequest<S>)
 where
     S: ScalarValue;
 
+impl<S: ScalarValue> AsRef<GraphQLBatchRequest<S>> for GraphQLRequest<S> {
+    fn as_ref(&self) -> &GraphQLBatchRequest<S> {
+        &self.0
+    }
+}
+
+impl<S: ScalarValue> AsMut<GraphQLBatchRequest<S>> for GraphQLRequest<S> {
+    fn as_mut(&mut self) -> &mut GraphQLBatchRequest<S> {
+        &mut self.0
+    }
+}
+
 /// Simple wrapper around the result of executing a GraphQL query
 pub struct GraphQLResponse(pub Status, pub String);
 


Test patch: