Add missing auto fields (#1212)

* add missing auto fields

* add missing auto fields

* skip small auto field sometimes

* make small auto optional

* make small auto optional
This commit is contained in:
Paul Bailey 2021-06-11 15:41:02 -05:00 committed by GitHub
parent 623d0f219e
commit e7f7d8da07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -166,11 +166,19 @@ def convert_field_to_string(field, registry=None):
) )
@convert_django_field.register(models.BigAutoField)
@convert_django_field.register(models.AutoField) @convert_django_field.register(models.AutoField)
def convert_field_to_id(field, registry=None): def convert_field_to_id(field, registry=None):
return ID(description=get_django_field_description(field), required=not field.null) return ID(description=get_django_field_description(field), required=not field.null)
if hasattr(models, "SmallAutoField"):
@convert_django_field.register(models.SmallAutoField)
def convert_field_small_to_id(field, registry=None):
return convert_field_to_id(field, registry)
@convert_django_field.register(models.UUIDField) @convert_django_field.register(models.UUIDField)
def convert_field_to_uuid(field, registry=None): def convert_field_to_uuid(field, registry=None):
return UUID( return UUID(

View File

@ -111,6 +111,15 @@ def test_should_auto_convert_id():
assert_conversion(models.AutoField, graphene.ID, primary_key=True) assert_conversion(models.AutoField, graphene.ID, primary_key=True)
def test_should_big_auto_convert_id():
assert_conversion(models.BigAutoField, graphene.ID, primary_key=True)
def test_should_small_auto_convert_id():
if hasattr(models, "SmallAutoField"):
assert_conversion(models.SmallAutoField, graphene.ID, primary_key=True)
def test_should_uuid_convert_id(): def test_should_uuid_convert_id():
assert_conversion(models.UUIDField, graphene.UUID) assert_conversion(models.UUIDField, graphene.UUID)