Merge branch 'v3' into v3-make-v3-django-choice-field-enum-daming-default

This commit is contained in:
Jonathan Kim 2020-06-10 17:26:12 +01:00 committed by GitHub
commit 7246d9df57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 60 deletions

View File

@ -119,7 +119,7 @@ def convert_django_field_with_choices(
def get_django_field_description(field): def get_django_field_description(field):
return None if field.help_text is None else str(field.help_text) return str(field.help_text) if field.help_text else None
@singledispatch @singledispatch
@ -230,11 +230,10 @@ def convert_field_to_list_or_connection(field, registry=None):
if not _type: if not _type:
return return
description = ( if isinstance(field, models.ManyToManyField):
field.help_text description = get_django_field_description(field)
if isinstance(field, models.ManyToManyField) else:
else field.field.help_text description = get_django_field_description(field.field)
)
# If there is a connection, we should transform the field # If there is a connection, we should transform the field
# into a DjangoConnectionField # into a DjangoConnectionField

View File

@ -845,7 +845,6 @@ def test_integer_field_filter_type():
} }
type PetType implements Node { type PetType implements Node {
\"""\"""
age: Int! age: Int!
\"""The ID of the object\""" \"""The ID of the object\"""
@ -915,7 +914,6 @@ def test_other_filter_types():
} }
type PetType implements Node { type PetType implements Node {
\"""\"""
age: Int! age: Int!
\"""The ID of the object\""" \"""The ID of the object\"""

View File

@ -30,9 +30,7 @@ def get_filtering_args_from_filterset(filterset_class, type):
form_field = filter_field.field form_field = filter_field.field
field_type = convert_form_field(form_field).Argument() field_type = convert_form_field(form_field).Argument()
field_type.description = ( field_type.description = str(filter_field.label) if filter_field.label else None
None if filter_field.label is None else str(filter_field.label)
)
args[name] = field_type args[name] = field_type
return args return args

View File

@ -9,7 +9,7 @@ from .forms import GlobalIDFormField, GlobalIDMultipleChoiceField
def get_form_field_description(field): def get_form_field_description(field):
return None if field.help_text is None else str(field.help_text) return str(field.help_text) if field.help_text else None
@singledispatch @singledispatch

View File

@ -121,26 +121,14 @@ def test_schema_representation():
type Article implements Node { type Article implements Node {
\"""The ID of the object\""" \"""The ID of the object\"""
id: ID! id: ID!
\"""\"""
headline: String! headline: String!
\"""\"""
pubDate: Date! pubDate: Date!
\"""\"""
pubDateTime: DateTime! pubDateTime: DateTime!
\"""\"""
reporter: Reporter! reporter: Reporter!
\"""\"""
editor: Reporter! editor: Reporter!
\"""Language\""" \"""Language\"""
lang: TestsArticleLangChoices! lang: TestsArticleLangChoices!
\"""\"""
importance: TestsArticleImportanceChoices importance: TestsArticleImportanceChoices
} }
@ -184,28 +172,13 @@ def test_schema_representation():
\"""Reporter description\""" \"""Reporter description\"""
type Reporter { type Reporter {
\"""\"""
id: ID! id: ID!
\"""\"""
firstName: String! firstName: String!
\"""\"""
lastName: String! lastName: String!
\"""\"""
email: String! email: String!
\"""\"""
pets: [Reporter!]! pets: [Reporter!]!
\"""\"""
aChoice: TestsReporterAChoiceChoices aChoice: TestsReporterAChoiceChoices
\"""\"""
reporterType: TestsReporterReporterTypeChoices reporterType: TestsReporterReporterTypeChoices
\"""\"""
articles(before: String = null, after: String = null, first: Int = null, last: Int = null): ArticleConnection! articles(before: String = null, after: String = null, first: Int = null, last: Int = null): ArticleConnection!
} }
@ -513,13 +486,8 @@ class TestDjangoObjectType:
} }
type Pet { type Pet {
\"""\"""
id: ID! id: ID!
\"""\"""
kind: String! kind: String!
\"""\"""
cuteness: Int! cuteness: Int!
} }
""" """
@ -543,13 +511,8 @@ class TestDjangoObjectType:
} }
type Pet { type Pet {
\"""\"""
id: ID! id: ID!
\"""\"""
kind: TestsPetModelKindChoices! kind: TestsPetModelKindChoices!
\"""\"""
cuteness: Int! cuteness: Int!
} }
@ -582,13 +545,8 @@ class TestDjangoObjectType:
} }
type Pet { type Pet {
\"""\"""
id: ID! id: ID!
\"""\"""
kind: String! kind: String!
\"""\"""
cuteness: Int! cuteness: Int!
} }
""" """
@ -614,10 +572,7 @@ class TestDjangoObjectType:
} }
type PetModelKind { type PetModelKind {
\"""\"""
id: ID! id: ID!
\"""\"""
kind: TestsPetModelKindChoices! kind: TestsPetModelKindChoices!
} }
@ -656,10 +611,7 @@ class TestDjangoObjectType:
} }
type PetModelKind { type PetModelKind {
\"""\"""
id: ID! id: ID!
\"""\"""
kind: CustomEnumKind! kind: CustomEnumKind!
} }