[Bug] Network errors are discarded.
还没有人认领这个 Issue。
评估
调研方向
从 lib/graphql/client/http.rb 中 Either 风格返回值附近的代码,以及 lib/graphql/schema/loader.rb 中 load_schema 使用 dump_schema 的位置开始。跟踪错误路径经过 load_schema 和提到的其他 execute 调用方(包括 query()),然后确认 HTTP 或 GraphQL 错误仍然可用,而不会变成 KeyError。
由索引模型根据 Issue 内容生成。
描述
If there's an HTTP error, calls to GraphQL::Client can return this:
KeyError: key not found: "data" (KeyError)
E.g., when I try the example in the readme to https://example.com/graphql, I expect some kind of network or HTTP error. Instead, I get the above KeyError.
I got this when making changes to my infrastructure. It made it very hard to debug problems.
I looked at load_schema, and found:
pry(main)> GraphQL::Client.load_schema(HTTP)
KeyError: key not found: "data" (KeyError)
from gems/3.4.0/gems/graphql-2.5.2/lib/graphql/schema/loader.rb:17:in 'Hash#fetch'
The load_schema call turns into load_schema(dump_schema(HTTP)). dump_schema seems to return full error info. So, between those two function calls, the information is lost:
[pry(main)> GraphQL::Client.dump_schema(HTTP)
=> {"errors" => [{"message" => "403 Forbidden"}]}
This happens other places that call execute, I believe, like .query().
In my opinion, the core problem is, the library uses fp-style Either error returns. However, Ruby doesn't have a way (like Rust or Haskell do) to enforce the handling of the error case. And so, it's possible to simply not handle them appropriately, like here.
Either-style API:
IMO, the fix is to use Ruby's Exception/Error facility so that library clients can meaningfully handle errors.
- 主要语言
- Ruby
- 星标
- 78
- 派生
- 228
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github-community-projects/graphql-client 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 45/100
github-community-projects/graphql-client#78 · 1 条评论 ·
-
难度 3/5 1-2 天 新手友好度 35/100
github-community-projects/graphql-client#77 · 2 条评论 ·
-
难度 5/5 一周以上 新手友好度 35/100
github-community-projects/graphql-client#76 · 4 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
github-community-projects/graphql-client#75 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 30/100
github-community-projects/graphql-client#65 · 1 条评论 ·
查看 github-community-projects/graphql-client 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
data error
难度 2/5 1-3 小时 新手友好度 82/100
riscv/riscv-unified-db#2648 ·
维护者通常 1 天内回复
-
P2 testing
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 1 天内回复