graphql-python / graphql-python/sanic-graphql

Per-request context

未关闭
#14 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
148
派生
17
PR 合并指标
30 天内没有已合并 PR

描述

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!

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。