Skip to content

Commit 5d0cf4a

Browse files
committed
DRF multiple choices field converts to list of enum
1 parent 02f0c23 commit 5d0cf4a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

graphene_django/rest_framework/serializer_converter.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ def convert_serializer_field_to_jsonstring(field):
136136

137137

138138
@get_graphene_type_from_serializer_field.register(serializers.MultipleChoiceField)
139-
def convert_serializer_field_to_list_of_string(field):
140-
return (graphene.List, graphene.String)
139+
def convert_serializer_field_to_list_of_enum(field):
140+
child_type = convert_serializer_field_to_enum(field)
141+
return (graphene.List, child_type)
141142

142143

143144
@get_graphene_type_from_serializer_field.register(serializers.ChoiceField)

graphene_django/rest_framework/tests/test_field_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ def test_should_json_convert_jsonstring():
194194
assert_conversion(serializers.JSONField, graphene.types.json.JSONString)
195195

196196

197-
def test_should_multiplechoicefield_convert_to_list_of_string():
197+
def test_should_multiplechoicefield_convert_to_list_of_enum():
198198
field = assert_conversion(
199199
serializers.MultipleChoiceField, graphene.List, choices=[1, 2, 3]
200200
)
201201

202-
assert field.of_type == graphene.String
202+
assert issubclass(field.of_type, graphene.Enum)

0 commit comments

Comments
 (0)