mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-22 01:27:01 +03:00
Register MultipleChoiceField as list type (#1033)
In general I welcome reviews even from non-maintainers to build confidence. I haven't seen any objections and this has sat with approval for a week so I am going to go ahead and merge.
This commit is contained in:
parent
4b7119d691
commit
4c0c821b74
|
@ -63,6 +63,11 @@ def convert_form_field_to_list(field):
|
|||
return List(ID, required=field.required)
|
||||
|
||||
|
||||
@convert_form_field.register(forms.MultipleChoiceField)
|
||||
def convert_form_field_to_string_list(field):
|
||||
return List(String, required=field.required)
|
||||
|
||||
|
||||
@convert_form_field.register(forms.DateField)
|
||||
def convert_form_field_to_date(field):
|
||||
return Date(description=field.help_text, required=field.required)
|
||||
|
|
|
@ -101,7 +101,14 @@ def test_should_decimal_convert_float():
|
|||
assert_conversion(forms.DecimalField, Float)
|
||||
|
||||
|
||||
def test_should_multiple_choice_convert_connectionorlist():
|
||||
def test_should_multiple_choice_convert_list():
|
||||
field = forms.MultipleChoiceField()
|
||||
graphene_type = convert_form_field(field)
|
||||
assert isinstance(graphene_type, List)
|
||||
assert graphene_type.of_type == String
|
||||
|
||||
|
||||
def test_should_model_multiple_choice_convert_connectionorlist():
|
||||
field = forms.ModelMultipleChoiceField(queryset=None)
|
||||
graphene_type = convert_form_field(field)
|
||||
assert isinstance(graphene_type, List)
|
||||
|
|
Loading…
Reference in New Issue
Block a user