1

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

模型.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

架构.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)
4

1 回答 1

1

我可以添加这样的描述:

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

超级简单!

于 2017-07-15T00:01:45.597 回答