|
1 | 1 | from django.db import models
|
2 | 2 | from django.utils.encoding import force_text
|
| 3 | +from django.utils.functional import Promise |
3 | 4 |
|
4 | 5 | from graphene import (
|
5 | 6 | ID,
|
|
20 | 21 | from graphene.types.json import JSONString
|
21 | 22 | from graphene.utils.str_converters import to_camel_case, to_const
|
22 | 23 | from graphql import assert_valid_name, GraphQLError
|
| 24 | +from graphql.pyutils import register_description |
23 | 25 |
|
24 | 26 | from .compat import ArrayField, HStoreField, JSONField, RangeField
|
25 | 27 | from .fields import DjangoListField, DjangoConnectionField
|
@@ -48,7 +50,7 @@ def get_choices(choices):
|
48 | 50 | while name in converted_names:
|
49 | 51 | name += "_" + str(len(converted_names))
|
50 | 52 | converted_names.append(name)
|
51 |
| - description = str(help_text) # TODO: translatable description: https://github.com/graphql-python/graphql-core-next/issues/58 |
| 53 | + description = help_text |
52 | 54 | yield name, value, description
|
53 | 55 |
|
54 | 56 |
|
@@ -245,3 +247,8 @@ def convert_posgres_range_to_string(field, registry=None):
|
245 | 247 | if not isinstance(inner_type, (List, NonNull)):
|
246 | 248 | inner_type = type(inner_type)
|
247 | 249 | return List(inner_type, description=field.help_text, required=not field.null)
|
| 250 | + |
| 251 | + |
| 252 | +# Register Django lazy()-wrapped values as GraphQL description/help_text. |
| 253 | +# This is needed for using lazy translations, see https://github.com/graphql-python/graphql-core-next/issues/58. |
| 254 | +register_description(Promise) |
0 commit comments