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

Per-request context #14

Open
DrPyser opened this issue Nov 21, 2018 · 0 comments
Open

Per-request context #14

DrPyser opened this issue Nov 21, 2018 · 0 comments

Comments

@DrPyser
Copy link

DrPyser commented Nov 21, 2018

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!

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

No branches or pull requests

1 participant