graphql-python / graphql-python/flask-graphql

passing context to GraphQLView no more supported?

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

描述

Hi and thanks for the geat job.

With 1.4.1 version I used to pass my DB session via the `context` option of the GraphQLView as still mentioned in the README (which should be updated).

Below is an exemple of what I was doing:

```python
# [...]

db_session = scoped_session(
sessionmaker(autocommit=False, autoflush=False, bind=engine))

# [...]

app.add_url_rule(
'/graphql', view_func=GraphQLView.as_view(
'graphql', schema=SCHEMA, graphiql=True,
context={'session': db_session}))

# [...]
```

It seems this is no more possible and I can't figure out how to pass the DB session to the GraphQLView. Any information and/or updated doc would be nice.

Any solution to continue passing DB session via the GraphQLView (or by any other way allowing to pass it at execution time) would be perfect.

**EDIT: for an undocumented but working solution [see @cockscomb 's comment](https://github.com/graphql-python/flask-graphql/issues/52#issuecomment-412773200)**

貢獻指南

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

研究方向

先從 README 中的 GraphQLView context 範例和 GraphQLView 進入點開始,然後將 1.4.1 的行為與連結留言中的未記錄 workaround 進行比較。完成的標準是確認一種受支援、可在執行時傳遞資料庫 session 的方式,並相應更新 README 或行為。

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

評估

技術堆疊
graphql, python
領域
api, backend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

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

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