add setting to disable enum conversion

This commit is contained in:
Jason Kraus 2018-10-19 11:04:51 -07:00
parent f76f38ef30
commit 4f58783fb9
2 changed files with 3 additions and 1 deletions

View File

@ -24,6 +24,7 @@ from graphql import assert_valid_name
from .compat import ArrayField, HStoreField, JSONField, RangeField
from .fields import DjangoListField, DjangoConnectionField
from .utils import import_single_dispatch
from .settings import graphene_settings
singledispatch = import_single_dispatch()
@ -58,7 +59,7 @@ def convert_django_field_with_choices(field, registry=None):
if converted:
return converted
choices = getattr(field, "choices", None)
if choices:
if choices and graphene_settings.GRAPHENE_CONVERT_CHOICES_TO_ENUMS:
meta = field.model._meta
name = to_camel_case("{}_{}".format(meta.object_name, field.name))
choices = list(get_choices(choices))

View File

@ -35,6 +35,7 @@ DEFAULTS = {
"RELAY_CONNECTION_ENFORCE_FIRST_OR_LAST": False,
# Max items returned in ConnectionFields / FilterConnectionFields
"RELAY_CONNECTION_MAX_LIMIT": 100,
"GRAPHENE_CONVERT_CHOICES_TO_ENUMS": True,
}
if settings.DEBUG: