DRF multiple choices field converts to list of enum

This commit is contained in:
Jason Kraus 2019-05-31 12:03:37 -07:00
parent 02f0c2347f
commit 5d0cf4a7ae
2 changed files with 5 additions and 4 deletions
graphene_django/rest_framework

View File

@ -136,8 +136,9 @@ def convert_serializer_field_to_jsonstring(field):
@get_graphene_type_from_serializer_field.register(serializers.MultipleChoiceField)
def convert_serializer_field_to_list_of_string(field):
return (graphene.List, graphene.String)
def convert_serializer_field_to_list_of_enum(field):
child_type = convert_serializer_field_to_enum(field)
return (graphene.List, child_type)
@get_graphene_type_from_serializer_field.register(serializers.ChoiceField)

View File

@ -194,9 +194,9 @@ def test_should_json_convert_jsonstring():
assert_conversion(serializers.JSONField, graphene.types.json.JSONString)
def test_should_multiplechoicefield_convert_to_list_of_string():
def test_should_multiplechoicefield_convert_to_list_of_enum():
field = assert_conversion(
serializers.MultipleChoiceField, graphene.List, choices=[1, 2, 3]
)
assert field.of_type == graphene.String
assert issubclass(field.of_type, graphene.Enum)