Add test and documentation note

That setting to an empty list is the same as setting the value as False
This commit is contained in:
Jonathan Kim 2019-06-14 15:07:32 +01:00
parent 380ad94b3b
commit 448802b2b6
2 changed files with 32 additions and 0 deletions

View File

@ -153,6 +153,9 @@ automatically converted into enums:
model = PetModel model = PetModel
convert_choices_to_enum = ['kind'] convert_choices_to_enum = ['kind']
**Note:** Setting ``convert_choices_to_enum`` to an empty list is the same as
setting it to `False`.
Related models Related models
-------------- --------------

View File

@ -303,3 +303,32 @@ class TestDjangoObjectType:
} }
""" """
) )
def test_django_objecttype_convert_choices_enum_empty_list(self, PetModel):
class Pet(DjangoObjectType):
class Meta:
model = PetModel
convert_choices_to_enum = []
class Query(ObjectType):
pet = Field(Pet)
schema = Schema(query=Query)
assert str(schema) == dedent(
"""\
schema {
query: Query
}
type Pet {
id: ID!
kind: String!
cuteness: Int!
}
type Query {
pet: Pet
}
"""
)