Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Associate GlobalIDFilter with BigAutoField and SmallAutoField #1496

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions graphene_django/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,13 @@ def convert_field_to_string(field, registry=None):
)


@convert_django_field.register(models.SmallAutoField)
@convert_django_field.register(models.BigAutoField)
@convert_django_field.register(models.AutoField)
def convert_field_to_id(field, registry=None):
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)
def convert_field_to_uuid(field, registry=None):
return UUID(
Expand Down
2 changes: 2 additions & 0 deletions graphene_django/filter/filterset.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

GRAPHENE_FILTER_SET_OVERRIDES = {
models.AutoField: {"filter_class": GlobalIDFilter},
models.BigAutoField: {"filter_class": GlobalIDFilter},
models.SmallAutoField: {"filter_class": GlobalIDFilter},
models.OneToOneField: {"filter_class": GlobalIDFilter},
models.ForeignKey: {"filter_class": GlobalIDFilter},
models.ManyToManyField: {"filter_class": GlobalIDMultipleChoiceFilter},
Expand Down
3 changes: 1 addition & 2 deletions graphene_django/tests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ def test_should_big_auto_convert_id():


def test_should_small_auto_convert_id():
if hasattr(models, "SmallAutoField"):
assert_conversion(models.SmallAutoField, graphene.ID, primary_key=True)
assert_conversion(models.SmallAutoField, graphene.ID, primary_key=True)


def test_should_uuid_convert_id():
Expand Down
Loading