graphql-python / graphql-python/sanic-graphql

Per-request context

オープン
#14 コメント 0 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。