Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access the JSON request body before the GraphQL engine does #339

Open
mwilliammyers opened this issue Apr 6, 2019 · 1 comment
Open
Labels
enhancement Improvement of existing features or bugfix

Comments

@mwilliammyers
Copy link

mwilliammyers commented Apr 6, 2019

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 Directives support? #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 mwilliammyers added the enhancement Improvement of existing features or bugfix label Apr 6, 2019
@theduke
Copy link
Member

theduke commented May 21, 2019

I've done something similar in the past by just copying the code in juniper_warp and adding my own logic in front.

Making the integration code a bit more extendable would be nice though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix
Projects
None yet
Development

No branches or pull requests

2 participants