Closed
Description
I was wondering why the public functions in juniper_hyper
return a Result<Response, hyper::Error>
instead of a simple Response
. And indeed, looking into the code, it looks like they always return Ok
. So clearly, right now, the Result
is not needed.
Is Result
used to plan for potential future scenarios where juniper_hyper
would want to return errors? I'm not sure if that makes sense:
- There is currently no public way to create a
hyper::Error
, so you could only forward errors returned by otherhyper
functions. - I don't see why
juniper_hyper
would ever use ahyper
function returning an error. There are not too many of those (e.g. awaiting theServer
results in aResult<(), hyper::Error>
). Most errors thathyper::Error
represents happen either when accepting/parsing the request or when sending the response: thejuniper_hyper
code is in between of that. Right now I don't see whathyper::Error
those functions could reasonably return. - Other errors (GraphQL parse errors and such) are already mapped to a BAD REQUEST response, not an
Err
.
If hyper
changes in the future, all this might change of course. But since updating the hyper
version requires a major version bump in juniper_hyper
anyway, I would think that right now, the public functions of juniper_hyper
should return a Response
directly.
Anything I'm missing?
Metadata
Metadata
Assignees
Labels
No labels