Skip to content

DjangoObjectType fields description #19

@r-abzalov

Description

@r-abzalov

Нужно добавить парсер параметра verbose_name Field-ов из модели ORM Django в description Field DjangoObjectType-a.
Чтобы это выглядело примерно так:

class User(AbstractUser):
    """Custom user model."""

    email = models.EmailField(verbose_name='Email address', unique=True)
    avatar = models.ImageField(verbose_name='Avatar image', null=True, blank=True, storage=S3AvatarStorage())
    username = models.CharField(verbose_name='Username', max_length=150, unique=True, null=True, blank=True)


class UserType(DjangoObjectType):
    """GraphQL type based on user model."""
    
    avatar = graphene.String(name='avatarUrl')
    username = graphene.String(description='Login for authentication')  # В случае если хотим кастомизировать описание для поля

     class Meta:
         model = User
         get_description_from_model = True

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions