关于客户端视图的Graphene-Python文档

时间:2017-07-14 22:23:40

标签: metadata graphene-python

客户端可以查看GraphQL架构元素上的description property。例如,GraphQL在预先输入下拉列表中显示字段对象的描述值,该下拉列表列出了选择集内可用的字段。同样的描述出现在documentation section上。可以通过graphene-gae添加这种类型的元数据文档吗?我的设置:

models.py:

class Article(ndb.Model):
    headline = ndb.StringProperty()
    author_key = ndb.KeyProperty(kind='Author')
    created_at = ndb.DateTimeProperty(auto_now_add=True)

import graphene
from graphene_gae import NdbObjectType

Schema.py:

class ArticleType(NdbObjectType):
    class Meta:
        model = Article

class Query(graphene.ObjectType):
    articles = graphene.List(ArticleType)

    @graphene.resolve_only_args
    def resolve_articles(self):
        return Article.query()

schema = graphene.Schema(query=QueryRoot)

1 个答案:

答案 0 :(得分:1)

我可以添加这样的说明:

headline = ndb.StringProperty(description='Add description here!')

超级简单!