graphql-python / graphql-python/sanic-graphql

Per-request context

Aperta
#14 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
148
Fork
17
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

What's the appropriate way to inject values into the context on a per-request basis? That is, I can statically set context values when I add the route, but is there a way to do so dynamically, per-request?

Looking at the code, I guess subclass I can override `GraphQLView.get_context` for that purpose. Is this the only way?

If so, I would suggest a "context_function" argument to `GraphQLView`, which would be a function that takes the request, and the default/current context, and returns a new context. This function would be called as part of `get_context`. This would avoid having to subclass the view only for such a simple(and probably pretty common) customization.

Thanks!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.