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

Request-level middleware #1117

Open
melvinkcx opened this issue Dec 23, 2019 · 3 comments
Open

Request-level middleware #1117

melvinkcx opened this issue Dec 23, 2019 · 3 comments
Assignees
Labels

Comments

@melvinkcx
Copy link

melvinkcx commented Dec 23, 2019

I'm using Graphene with Django, and I have a middleware that checks user auth token. I'm having an issue with the middleware being executed at the field-level. Each field resolution triggers a call to check user's token in my case.

Any suggestions to improve this? Any plans for supporting request-level middleware?

I have some idea:

  1. Move auth checking into a Django middleware, but that means any exception raised will not be serialized into GraphQLResponse.
  2. Add a flag is_authenticated into info.context object, if the value of info.context.is_authenticated is True, skip the middleware by calling next()
@melvinkcx
Copy link
Author

I just released graphql-utilities including utilities to support operation-level only middleware. It targets graphql-core>=3.0 (or graphql-core-next), feel free to check it out.

@stale
Copy link

stale bot commented Apr 30, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 30, 2020
@stale stale bot closed this as completed May 14, 2020
@erikwrede erikwrede reopened this Sep 23, 2022
@erikwrede erikwrede self-assigned this Sep 23, 2022
@erikwrede
Copy link
Member

Looks interesting, I will have a deeper look into this soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants