fix: Fix broken 'get_choices' with restframework 3.15.0 by diogosilva30 · Pull Request #1506 · graphql-python/graphene-django (original) (raw)
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.