Return Response<String>
instead of Response<Body>
in hyper integration
#1096
Labels
enhancement
Improvement of existing features or bugfix
k::integration
Related to integration with third-party libraries or systems
Milestone
Is your feature request related to a problem? Please describe.
Sometimes it's useful to inspect the response returned by
juniper_hyper::graphql
. For example, in case of an error I would like to debug-log the whole JSON response. This is currently very tricky.The function returns
Response<Body>
and the only way to read thatBody
is via theStream
trait (or the helper functions inhyper::body
which also use that trait). But all those methods requireBody
by value or&mut Body
. And in general that makes sense:Body
can be many things and is not necessarily a byte buffer.The best I could come up with to log the body is:
I need to completely unpack the response to then assemble it again. And the
await
andexpect
are both not nice here.Describe the solution you'd like
From a quick glance at the
juniper_hyper
code, it seems like theBody
is always created viaFrom<String>
. ButString
implements the traithyper::HttpBody
directly! So my suggestion is that all functions returnResponse<String>
. With that, my logging would be as simple as:The text was updated successfully, but these errors were encountered: