graphql-python / graphql-python/flask-graphql

Flask's app.errorhandler decorator dosen't work for GraphQLLocatedError

未關閉
#49 1 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

主要語言
Python
星號
1.3k
分支
139
PR 合併指標
30 天內沒有已合併 PR

描述

I am making an extension library [flask-graphql-auth](https://github.com/devArtoria/flask-graphql-auth). and error handler by using flask's app.errorhandler is being planed for the 1.0 release. I checked that if my library caused an exception like JWTDecodeError, an GraphQLLocatedError occurred. However, the flask can not handle the error by app.errorhandler. Is this a bug?

```
@app.errorhandler(GraphQLLocatedError)
def handle(e):
return 401
```
I wrote this code. but stacktrace appears :(
```
...
Traceback (most recent call last):
File "C:\Users\Lewis\OneDrive\Documents\Development Repos\flask-graphql-auth\venv\lib\site-packages\graphql\execution\executor.py", line 330, in complete_value_catching_error
exe_context, return_type, field_asts, info, result)
File "C:\Users\Lewis\OneDrive\Documents\Development Repos\flask-graphql-auth\venv\lib\site-packages\graphql\execution\executor.py", line 383, in complete_value
raise GraphQLLocatedError(field_asts, original_error=result)
graphql.error.located_error.GraphQLLocatedError: Signature verification failed
127.0.0.1 - - [21/Jul/2018 12:48:30] "POST /graphql? HTTP/1.1" 200 -
```

貢獻指南

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

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 graphql/execution/executor.py 開始,特別查看 complete_value_catching_error 和 complete_value,然後追蹤 /graphql 請求直到 Flask 的 app.errorhandler 註冊處。釐清 GraphQLLocatedError 為什麼會繞過所回報的 handler;完成的標準是 handler 行為受到可重現的涵蓋,且該 exception 不再繞過 Flask 錯誤處理。

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

評估

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

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

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