Python graphene 模块,Node() 实例源码
我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用graphene.Node()。
def setup_fixtures():
class ReporterType(PynamoObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
class ArticleType(PynamoObjectType):
class Meta:
model = Article
interfaces = (Node,)
reporter1 = Reporter(1, first_name="John", last_name="SNow")
article1 = Article(1, headline="Hi!", reporter=reporter1)
article2 = Article(2, headline="Lame Article", reporter=reporter1)
reporter1.articles = [article1, article2]
return {
'ReporterType': ReporterType,
'ArticleType': ArticleType,
'reporter1': reporter1,
'article1': article1,
'article2': article2
}
def test_should_onetoone_convert_field():
class A(PynamoObjectType):
class Meta:
model = Article
interfaces = (Node,)
dynamic_field = convert_pynamo_attribute(Reporter.favorite_article, Reporter.favorite_article, A._Meta.registry)
assert isinstance(dynamic_field, Dynamic)
graphene_type = dynamic_field.get_type()
assert isinstance(graphene_type, graphene.Field)
assert graphene_type.type == A
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。