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

[FEATURE] added convert_choices_to_enum optional argument to convert_serializer_to_input_type #1517

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions graphene_django/rest_framework/serializer_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def convert_serializer_field(
return graphql_type(*args, **kwargs)


def convert_serializer_to_input_type(serializer_class):
def convert_serializer_to_input_type(serializer_class, convert_choices_to_enum=True):
cached_type = convert_serializer_to_input_type.cache.get(
serializer_class.__name__, None
)
Expand All @@ -73,7 +73,9 @@ def convert_serializer_to_input_type(serializer_class):
serializer = serializer_class()

items = {
name: convert_serializer_field(field)
name: convert_serializer_field(
field, convert_choices_to_enum=convert_choices_to_enum
)
for name, field in serializer.fields.items()
}
ret_type = type(
Expand Down