Skip to content

Commit 1a04d60

Browse files
committed
Add support for MultipleChoiceField
1 parent 510ee93 commit 1a04d60

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

graphene_django/rest_framework/serializer_converter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,8 @@ def convert_serializer_field_to_dict(field):
9191
@get_graphene_type_from_serializer_field.register(serializers.JSONField)
9292
def convert_serializer_field_to_jsonstring(field):
9393
return graphene.types.json.JSONString
94+
95+
96+
@get_graphene_type_from_serializer_field.register(serializers.MultipleChoiceField)
97+
def convert_serializer_field_to_list_of_string(field):
98+
return (graphene.List, graphene.String)

graphene_django/rest_framework/tests/test_field_converter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,9 @@ def test_should_image_convert_string():
144144

145145
def test_should_json_convert_jsonstring():
146146
assert_conversion(serializers.JSONField, graphene.types.json.JSONString)
147+
148+
149+
def test_should_multiplechoicefield_convert_to_list_of_string():
150+
field = assert_conversion(serializers.MultipleChoiceField, graphene.List, choices=[1,2,3])
151+
152+
assert field.of_type == graphene.String

0 commit comments

Comments
 (0)