graphql-python / graphql-python/flask-graphql

Proposal: Pass custom variables to graphiql template

未關閉
#35 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
1.3k
分支
139
PR 合併指標
30 天內沒有已合併 PR

描述

Hi !

It would be nice to be able to pass arbitrary variables to the graphiql template. I didn't found how to do it and looking at how `render_graphiql.py` is called, it seems that this is not possible.

I found a workaround by pre-formatting my template before passing it to `GraphQLView.as_view()` but it felt awkward.
Maybe something like this would look nicer:

```python
view_func = GraphQLView.as_view(
url,
schema,
graphiql=True,
graphiql_template=my_custom_template,
graphiql_template_context={"username": username} # Now I can greet the user on my custom page !
)
```

If you guys are interested by this proposal let me know and I'll do a PR in the next few days.

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

首先閱讀 render_graphiql.py 和 GraphQLView.as_view() 入口點,以了解 GraphiQL 範本是如何轉譯的。新增支援,以便透過檢視設定傳遞任意範本內容,並驗證 username 之類的自訂變數在轉譯後的範本中可用。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
flask, python
領域
api, backend
Issue 類型
功能
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。