mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-29 04:53:43 +03:00
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:
parent
623d0f219e
commit
e7f7d8da07
|
@ -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(
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user