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)**

贡献指南

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

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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