Graphene-django: Question: How can I add description

Created on 5 Jul 2017  路  6Comments  路  Source: graphql-python/graphene-django

Should I be adding description to meta class of DjangoObjectType?

Update:

Adding description to meta class of DjangoObjectType did not do anything.

Most helpful comment

What about description for model fields?
How can I attach description for the fields of ChannelNode (name, customer etc...)?

All 6 comments

Can you provide a code snippet?
Here is a working example of mine :

class ChannelNode(DjangoObjectType):
    class Meta:
        model = Channel
        filter_fields = {'name': ['exact', 'icontains', 'istartswith'],
                         'customer': ['exact', 'icontains', 'istartswith']}
        interfaces = (relay.Node,)
        description = "This is a Channel Node"

If you navigate on ChannelNode on the GraphiQl you will see the description.

Awesome that's what I wanted to know. Thanks for the help.

What about description for model fields?
How can I attach description for the fields of ChannelNode (name, customer etc...)?

@itaied246 Might want to open a new request

@itaied246

What about description for model fields?
How can I attach description for the fields of ChannelNode (name, customer etc...)?

just pass a parameter like this
DjangoFilterConnectionField(PageNode, description='test')
or still you can create meta class:

class MenuNode(DjangoObjectType):
    class Meta:
        model = MenuModel
        interfaces = (graphene.relay.Node, )
        description = 'menu node'

in additional to all above you can rename your fields just create in class Meta var name='bla_bla'
only restriction no spaces and other special symbols. You can use this pattern to ensure:
Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/

So i just tried this with no luck. Am I doing somthing wrong or has something changed?

from graphene_django import DjangoObjectType
from .models import Question as QuestionModel
import graphene

class Question(DjangoObjectType):
    class Meta:
        model = QuestionModel
        description = "This is a Question"
Was this page helpful?
0 / 5 - 0 ratings

Related issues

flame0 picture flame0  路  4Comments

x9sheikh picture x9sheikh  路  4Comments

dan-klasson picture dan-klasson  路  4Comments

artofhuman picture artofhuman  路  3Comments

licx picture licx  路  3Comments