Skip to content

Commit 5289cd0

Browse files
committed
Improved choice Enum converter
1 parent 854aa4a commit 5289cd0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

graphene_django/converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from graphene.relay import is_node
77
from graphene.types.datetime import DateTime
88
from graphene.types.json import JSONString
9-
from graphene.utils.str_converters import to_const
9+
from graphene.utils.str_converters import to_camel_case, to_const
1010
from graphql import assert_valid_name
1111

1212
from .compat import (ArrayField, HStoreField, JSONField, RangeField,
@@ -41,7 +41,7 @@ def convert_django_field_with_choices(field, registry=None):
4141
choices = getattr(field, 'choices', None)
4242
if choices:
4343
meta = field.model._meta
44-
name = '{}{}'.format(meta.object_name, field.name.capitalize())
44+
name = to_camel_case('{}_{}'.format(meta.object_name, field.name))
4545
choices = list(get_choices(choices))
4646
named_choices = [(c[0], c[1]) for c in choices]
4747
named_choices_descriptions = {c[0]: c[2] for c in choices}

graphene_django/tests/test_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ def test_schema_representation():
110110
lastName: String!
111111
email: String!
112112
pets: [Reporter]
113-
aChoice: ReporterA_choice!
113+
aChoice: ReporterAChoice!
114114
articles(before: String, after: String, first: Int, last: Int): ArticleConnection
115115
}
116116
117-
enum ReporterA_choice {
117+
enum ReporterAChoice {
118118
A_1
119119
A_2
120120
}

0 commit comments

Comments
 (0)