mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-02-26 08:30:47 +03:00
Improved choice Enum converter
This commit is contained in:
parent
854aa4aa9b
commit
5289cd06d7
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user