juniper icon indicating copy to clipboard operation
juniper copied to clipboard

Access the JSON request body before the GraphQL engine does

Open mwilliammyers opened this issue 5 years ago • 1 comments

Is your feature request related to a problem? Please describe. (only tested using the juniper_warp integration)

Currently every time I try to read the JSON body of the request before Juniper does (via a warp::body::json() anywhere in the filters chain), I get an error like :

{
  "error": "Unexpected token R in JSON at position 0"
}

Describe the solution you'd like I would love to be able to dynamically handle the request body in my context_extractor or otherwise read the request body before the GraphQL engine does.

I am not sure if this is unique to the juniper_warp integration or if there is some undocumented way of accomplishing this.

Describe alternatives you've considered

  • Handling the JSON body in every single query/mutation using lookaheads or something.
  • Custom schema directives would work well but I am not sure how well they are supported given #156.

Additional context I am trying to implement auth verification (via a basic auth header) for every query/mutation except the login mutation and the introspection query.

For now I just want to manually parse the JWT and immediately respond with an unauthorized error. Eventually it would be awesome to use a builtin auth filter to accomplish this.

mwilliammyers avatar Apr 06 '19 21:04 mwilliammyers