graphql-python / graphql-python/graphene
Request-level middleware
- Vorherrschende Sprache
- Python
- Sterne
- 8.2k
- Forks
- 818
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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()`
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.