mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-07 15:10:35 +03:00
Default return_field_name is camcelcased
This commit is contained in:
parent
40610c64a3
commit
d6dbe2a4a8
|
@ -131,7 +131,11 @@ class DjangoModelFormMutation(BaseDjangoFormMutation):
|
|||
|
||||
registry = get_global_registry()
|
||||
model_type = registry.get_type_for_model(model)
|
||||
return_field_name = return_field_name or model._meta.model_name
|
||||
return_field_name = return_field_name
|
||||
if not return_field_name:
|
||||
model_name = model.__name__
|
||||
return_field_name = model_name[:1].lower() + model_name[1:]
|
||||
|
||||
output_fields = OrderedDict()
|
||||
output_fields[return_field_name] = graphene.Field(model_type)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ from django import forms
|
|||
from django.test import TestCase
|
||||
from py.test import raises
|
||||
|
||||
from graphene_django.tests.models import Pet, Film
|
||||
from graphene_django.tests.models import Pet, Film, FilmDetails
|
||||
from ..mutation import DjangoFormMutation, DjangoModelFormMutation
|
||||
|
||||
|
||||
|
@ -52,6 +52,15 @@ class ModelFormMutationTests(TestCase):
|
|||
self.assertEqual(PetMutation._meta.return_field_name, 'pet')
|
||||
self.assertIn('pet', PetMutation._meta.fields)
|
||||
|
||||
def test_return_field_name_is_camelcased(self):
|
||||
class PetMutation(DjangoModelFormMutation):
|
||||
class Meta:
|
||||
form_class = PetForm
|
||||
model = FilmDetails
|
||||
|
||||
self.assertEqual(PetMutation._meta.model, FilmDetails)
|
||||
self.assertEqual(PetMutation._meta.return_field_name, 'filmDetails')
|
||||
|
||||
def test_custom_return_field_name(self):
|
||||
class PetMutation(DjangoModelFormMutation):
|
||||
class Meta:
|
||||
|
|
Loading…
Reference in New Issue
Block a user