graphql-python / graphql-python/graphene-sqlalchemy

Examples don't work

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

描述

Hi,

I followed the flask-sqlalchemy examples [here](https://github.com/graphql-python/graphene-sqlalchemy/blob/master/examples/flask_sqlalchemy) (and the snippets in the project's Readme as well) but it didn't work out of the box. I had the following exception: `AttributeError: 'Request' object has no attribute 'get'` when trying to request from Graphiql.

After some fiddling with flask-sqlalchemy i solved the bug by passing a `context` argument to `GraphQLView.as_view`.

Here is my full url declaration:
```python
app.add_url_rule(
'/graphql',
view_func=GraphQLView.as_view(
'graphql',
schema=schema,
graphiql=True,
context={'session': db_session}
),
)
```

I don't know if this is the proper way to fix the problem, but thought it'll be useful to tell you about it.

貢獻指南

開啟貢獻指南

研究方向

Start by running the examples/flask_sqlalchemy example and checking the GraphQLView.as_view usage shown there and in the README. Reproduce the GraphiQL request that raises the Request.get exception, then verify the context handling and ensure the example works out of the box or clearly documents the required configuration.

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

評估

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

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

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