mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-05-10 19:03:46 +03:00
DRF multiple choices field converts to list of enum
This commit is contained in:
parent
02f0c2347f
commit
5d0cf4a7ae
graphene_django/rest_framework
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user