mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-22 09:37:07 +03:00
fix: convert Django BigIntegerField to BigInt GraphQL type (#1318)
Co-authored-by: Thomas Leonard <thomas@loftorbital.com>
This commit is contained in:
parent
3473fe025e
commit
37848fa2df
|
@ -24,6 +24,7 @@ from graphene import (
|
|||
Decimal,
|
||||
)
|
||||
from graphene.types.json import JSONString
|
||||
from graphene.types.scalars import BigInt
|
||||
from graphene.utils.str_converters import to_camel_case
|
||||
from graphql import GraphQLError, assert_valid_name
|
||||
from graphql.pyutils import register_description
|
||||
|
@ -186,10 +187,14 @@ def convert_field_to_uuid(field, registry=None):
|
|||
)
|
||||
|
||||
|
||||
@convert_django_field.register(models.BigIntegerField)
|
||||
def convert_big_int_field(field, registry=None):
|
||||
return BigInt(description=field.help_text, required=not field.null)
|
||||
|
||||
|
||||
@convert_django_field.register(models.PositiveIntegerField)
|
||||
@convert_django_field.register(models.PositiveSmallIntegerField)
|
||||
@convert_django_field.register(models.SmallIntegerField)
|
||||
@convert_django_field.register(models.BigIntegerField)
|
||||
@convert_django_field.register(models.IntegerField)
|
||||
def convert_field_to_int(field, registry=None):
|
||||
return Int(description=get_django_field_description(field), required=not field.null)
|
||||
|
|
|
@ -10,6 +10,7 @@ from graphene import NonNull
|
|||
from graphene.relay import ConnectionField, Node
|
||||
from graphene.types.datetime import Date, DateTime, Time
|
||||
from graphene.types.json import JSONString
|
||||
from graphene.types.scalars import BigInt
|
||||
|
||||
from ..compat import (
|
||||
ArrayField,
|
||||
|
@ -140,8 +141,8 @@ def test_should_small_integer_convert_int():
|
|||
assert_conversion(models.SmallIntegerField, graphene.Int)
|
||||
|
||||
|
||||
def test_should_big_integer_convert_int():
|
||||
assert_conversion(models.BigIntegerField, graphene.Int)
|
||||
def test_should_big_integer_convert_big_int():
|
||||
assert_conversion(models.BigIntegerField, BigInt)
|
||||
|
||||
|
||||
def test_should_integer_convert_int():
|
||||
|
|
Loading…
Reference in New Issue
Block a user