graphql-python / graphql-python/graphene

In 3.1.0, `resolve_type` method on Interfaces and Unions no longer supports returning the GraphQL Type as a string

未关闭
#1,555 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
🐛 bug
主要语言
Python
星标
8.2k
派生
818
PR 合并指标
30 天内没有已合并 PR

描述

* **What is the current behavior?**
As of 3.1.0, the `resolve_type` method on Interfaces and Unions no longer supports returning the GraphQL Type as a string as opposed to the actual Graphene Type. I think this might be an unintended regression from https://github.com/graphql-python/graphene/pull/1421.

* **What is the expected behavior?**
Our project heavily depends on resolve_type returning a string for the GraphQL Type as opposed to the Graphene Type that implements it.

* **What is the motivation / use case for changing the behavior?**
While it's possible to refactor most of our code to return the Graphene Type, there are some cases where it's very difficult to break circular imports. The reason for that is that some of our implementations of the `resolve_type` method delegates to returning a property of an Enum and the Enum definition can't reference the Graphene Type because the Graphene Type references the enum.

* **Please tell us about your environment:**

- Version: Trying to upgrade to 3.1.0.
- Platform: Python 3.12.2 on Linux

* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
I created https://github.com/perlow/graphene/pull/1 in a fork. I don't have write permission the repo to request a merge. If this looks reasonable, I can add a unit test for the behavior.

贡献指南

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

调研方向

首先检查此处描述的 3.1.0 回归中更改的 resolve_type 处理,并将其与链接的 fork pull request 中提出的更改进行比较。添加一个覆盖字符串 GraphQL 类型结果的单元测试,然后运行相关测试套件,并确认该行为正常工作且不会破坏 Graphene Type 结果。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

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