Skip to content

Commit d6dbe2a

Browse files
author
Grant McConnaughey
committed
Default return_field_name is camcelcased
1 parent 40610c6 commit d6dbe2a

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

graphene_django/forms/mutation.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ def __init_subclass_with_meta__(cls, form_class=None, model=None, return_field_n
131131

132132
registry = get_global_registry()
133133
model_type = registry.get_type_for_model(model)
134-
return_field_name = return_field_name or model._meta.model_name
134+
return_field_name = return_field_name
135+
if not return_field_name:
136+
model_name = model.__name__
137+
return_field_name = model_name[:1].lower() + model_name[1:]
138+
135139
output_fields = OrderedDict()
136140
output_fields[return_field_name] = graphene.Field(model_type)
137141

graphene_django/forms/tests/test_mutation.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from django.test import TestCase
33
from py.test import raises
44

5-
from graphene_django.tests.models import Pet, Film
5+
from graphene_django.tests.models import Pet, Film, FilmDetails
66
from ..mutation import DjangoFormMutation, DjangoModelFormMutation
77

88

@@ -52,6 +52,15 @@ class Meta:
5252
self.assertEqual(PetMutation._meta.return_field_name, 'pet')
5353
self.assertIn('pet', PetMutation._meta.fields)
5454

55+
def test_return_field_name_is_camelcased(self):
56+
class PetMutation(DjangoModelFormMutation):
57+
class Meta:
58+
form_class = PetForm
59+
model = FilmDetails
60+
61+
self.assertEqual(PetMutation._meta.model, FilmDetails)
62+
self.assertEqual(PetMutation._meta.return_field_name, 'filmDetails')
63+
5564
def test_custom_return_field_name(self):
5665
class PetMutation(DjangoModelFormMutation):
5766
class Meta:

0 commit comments

Comments
 (0)