Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix broken 'get_choices' with restframework 3.15.0 #1506

Merged

Conversation

diogosilva30
Copy link
Contributor

With the latest changes in restframework 3.15.0 (Release notes), it looks like the get_choices field in converter.py file is broken when provided with integer choices. I looked into it and the cause was that rest-framework is no longer using OrderedDict, and instead providing a regular dict, which causes the current code to miss the following if statement:

if isinstance(choices, OrderedDict):
        choices = choices.items()

Simply switching OrderedDict to dict should suffice and be retro-compatible, since an OrderedDict is ultimately a dictionary. I have tested this change and it works.

@diogosilva30 diogosilva30 changed the title fix: Fix broke 'get_choices' with restframework 3.15.0 fix: Fix broken 'get_choices' with restframework 3.15.0 Mar 17, 2024
Copy link
Collaborator

@sjdemartini sjdemartini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and fixing!

@kiendang kiendang merged commit ac09cd2 into graphql-python:main Mar 18, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serializer mutation choice field creation fails with django-rest-framework 3.15.0
3 participants