graphql-python / graphene-django

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.
http://docs.graphene-python.org/projects/django/en/latest/
MIT License
4.28k stars 766 forks source link

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

Closed diogosilva30 closed 5 months ago

diogosilva30 commented 5 months ago

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.