Add support for MultipleChoiceField

This commit is contained in:
Patrick Arminio 2017-06-26 14:32:57 +01:00
parent 510ee9383e
commit 1a04d608ed
2 changed files with 11 additions and 0 deletions

View File

@ -91,3 +91,8 @@ def convert_serializer_field_to_dict(field):
@get_graphene_type_from_serializer_field.register(serializers.JSONField)
def convert_serializer_field_to_jsonstring(field):
return graphene.types.json.JSONString
@get_graphene_type_from_serializer_field.register(serializers.MultipleChoiceField)
def convert_serializer_field_to_list_of_string(field):
return (graphene.List, graphene.String)

View File

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