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

Open
#1,555 1 comment 0 reactions 0 assignees View on GitHub
🐛 bug
Dominant language
Python
Stars
8.2k
Forks
818
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the resolve_type handling changed in the 3.1.0 regression described here and compare it with the proposed change in the linked fork pull request. Add a unit test covering a string GraphQL type result, then run the relevant test suite and confirm the behavior works without breaking Graphene Type results.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.