diff --git a/graphene_django/converter.py b/graphene_django/converter.py index 22df6ca..70b364c 100644 --- a/graphene_django/converter.py +++ b/graphene_django/converter.py @@ -6,7 +6,7 @@ from graphene import (ID, Boolean, Dynamic, Enum, Field, Float, Int, List, from graphene.relay import is_node from graphene.types.datetime import DateTime from graphene.types.json import JSONString -from graphene.utils.str_converters import to_const +from graphene.utils.str_converters import to_camel_case, to_const from graphql import assert_valid_name from .compat import (ArrayField, HStoreField, JSONField, RangeField, @@ -41,7 +41,7 @@ def convert_django_field_with_choices(field, registry=None): choices = getattr(field, 'choices', None) if choices: meta = field.model._meta - name = '{}{}'.format(meta.object_name, field.name.capitalize()) + name = to_camel_case('{}_{}'.format(meta.object_name, field.name)) choices = list(get_choices(choices)) named_choices = [(c[0], c[1]) for c in choices] named_choices_descriptions = {c[0]: c[2] for c in choices} diff --git a/graphene_django/tests/test_types.py b/graphene_django/tests/test_types.py index 5d65551..c617fe4 100644 --- a/graphene_django/tests/test_types.py +++ b/graphene_django/tests/test_types.py @@ -110,11 +110,11 @@ type Reporter { lastName: String! email: String! pets: [Reporter] - aChoice: ReporterA_choice! + aChoice: ReporterAChoice! articles(before: String, after: String, first: Int, last: Int): ArticleConnection } -enum ReporterA_choice { +enum ReporterAChoice { A_1 A_2 }