Graphene-django: How to add description to fields?

Created on 12 Aug 2019  路  4Comments  路  Source: graphql-python/graphene-django

It is connected to #208, to this comment
Let's say I have this model:

class Country(models.Model):
    code = models.CharField(max_length=5, null=True)
    name = models.CharField(max_length=100, null=True)

and in schema i have

class CountryNode(DjangoObjectType):
    class Meta:
        model = Country
        description = "This is a Country Node"

I can add a description for CountryNode itself, but how to do it for Country code and name?

wontfix

Most helpful comment

you can define a field with same name in your DjangoObjectType if you do not want update the model 馃槃

class CountryNode(DjangoObjectType):`
    class Meta:
        model = Country
        description = "This is a Country Node"

    code = graphene.String(description="This is a code field")

All 4 comments

code = models.CharField(max_length=5, null=True, help_text="This is a code field")

you can define a field with same name in your DjangoObjectType if you do not want update the model 馃槃

class CountryNode(DjangoObjectType):`
    class Meta:
        model = Country
        description = "This is a Country Node"

    code = graphene.String(description="This is a code field")

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Closing this issue @Dawidpol because @dan-klasson and @liupengf12 have provided some solutions to the problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

x9sheikh picture x9sheikh  路  4Comments

amiyatulu picture amiyatulu  路  3Comments

licx picture licx  路  3Comments

StefanoSega picture StefanoSega  路  4Comments

timothyjlaurent picture timothyjlaurent  路  3Comments