本文整理汇总了Python中graphene.relay.Node方法的典型用法代码示例。如果您正苦于以下问题:Python relay.Node方法的具体用法?Python relay.Node怎么用?Python relay.Node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graphene.relay
的用法示例。
在下文中一共展示了relay.Node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filter_filterset_information_on_meta_related
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_filter_filterset_information_on_meta_related():
class ReporterFilterNode(DjangoObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
filter_fields = ["first_name", "articles"]
class ArticleFilterNode(DjangoObjectType):
class Meta:
model = Article
interfaces = (Node,)
filter_fields = ["headline", "reporter"]
class Query(ObjectType):
all_reporters = DjangoFilterConnectionField(ReporterFilterNode)
all_articles = DjangoFilterConnectionField(ArticleFilterNode)
reporter = Field(ReporterFilterNode)
article = Field(ArticleFilterNode)
schema = Schema(query=Query)
articles_field = ReporterFilterNode._meta.fields["articles"].get_type()
assert_arguments(articles_field, "headline", "reporter")
assert_not_orderable(articles_field)
示例2: test_recursive_filter_connection
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_recursive_filter_connection():
class ReporterFilterNode(DjangoObjectType):
child_reporters = DjangoFilterConnectionField(lambda: ReporterFilterNode)
def resolve_child_reporters(self, **args):
return []
class Meta:
model = Reporter
interfaces = (Node,)
class Query(ObjectType):
all_reporters = DjangoFilterConnectionField(ReporterFilterNode)
assert (
ReporterFilterNode._meta.fields["child_reporters"].node_type
== ReporterFilterNode
)
示例3: test_pynamo_interface
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_pynamo_interface():
assert issubclass(Node, Interface)
assert issubclass(Node, Node)
示例4: test_should_onetoone_convert_field
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_should_onetoone_convert_field():
class A(PynamoObjectType):
class Meta:
model = Article
interfaces = [relay.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
示例5: test_should_onetomany_convert_field
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_should_onetomany_convert_field():
class A(PynamoObjectType):
class Meta:
model = Article
interfaces = (Node,)
dynamic_field = convert_pynamo_attribute(Reporter.articles, Reporter.articles, A._meta.registry)
assert isinstance(dynamic_field, Dynamic)
graphene_type = dynamic_field.get_type()
assert isinstance(graphene_type, PynamoConnectionField)
示例6: get_schema
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def get_schema():
class ReporterType(SQLAlchemyObjectType):
class Meta:
model = Reporter
interfaces = (relay.Node,)
connection_field_factory = BatchSQLAlchemyConnectionField.from_relationship
class ArticleType(SQLAlchemyObjectType):
class Meta:
model = Article
interfaces = (relay.Node,)
connection_field_factory = BatchSQLAlchemyConnectionField.from_relationship
class PetType(SQLAlchemyObjectType):
class Meta:
model = Pet
interfaces = (relay.Node,)
connection_field_factory = BatchSQLAlchemyConnectionField.from_relationship
class Query(graphene.ObjectType):
articles = graphene.Field(graphene.List(ArticleType))
reporters = graphene.Field(graphene.List(ReporterType))
def resolve_articles(self, info):
return info.context.get('session').query(Article).all()
def resolve_reporters(self, info):
return info.context.get('session').query(Reporter).all()
return graphene.Schema(query=Query)
示例7: test_should_manytomany_convert_connectionorlist_connection
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_should_manytomany_convert_connectionorlist_connection():
class A(SQLAlchemyObjectType):
class Meta:
model = Pet
interfaces = (Node,)
dynamic_field = convert_sqlalchemy_relationship(
Reporter.pets.property, A, default_connection_field_factory, True, 'orm_field_name',
)
assert isinstance(dynamic_field, graphene.Dynamic)
assert isinstance(dynamic_field.get_type(), UnsortedSQLAlchemyConnectionField)
示例8: test_should_manytoone_convert_connectionorlist_connection
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_should_manytoone_convert_connectionorlist_connection():
class A(SQLAlchemyObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
dynamic_field = convert_sqlalchemy_relationship(
Article.reporter.property, A, default_connection_field_factory, True, 'orm_field_name',
)
assert isinstance(dynamic_field, graphene.Dynamic)
graphene_type = dynamic_field.get_type()
assert isinstance(graphene_type, graphene.Field)
assert graphene_type.type == A
示例9: test_should_onetoone_convert_field
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_should_onetoone_convert_field():
class A(SQLAlchemyObjectType):
class Meta:
model = Article
interfaces = (Node,)
dynamic_field = convert_sqlalchemy_relationship(
Reporter.favorite_article.property, A, default_connection_field_factory, True, 'orm_field_name',
)
assert isinstance(dynamic_field, graphene.Dynamic)
graphene_type = dynamic_field.get_type()
assert isinstance(graphene_type, graphene.Field)
assert graphene_type.type == A
示例10: get_schema
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def get_schema():
class ReporterType(SQLAlchemyObjectType):
class Meta:
model = Reporter
interfaces = (relay.Node,)
batching = True
class ArticleType(SQLAlchemyObjectType):
class Meta:
model = Article
interfaces = (relay.Node,)
batching = True
class PetType(SQLAlchemyObjectType):
class Meta:
model = Pet
interfaces = (relay.Node,)
batching = True
class Query(graphene.ObjectType):
articles = graphene.Field(graphene.List(ArticleType))
reporters = graphene.Field(graphene.List(ReporterType))
def resolve_articles(self, info):
return info.context.get('session').query(Article).all()
def resolve_reporters(self, info):
return info.context.get('session').query(Reporter).all()
return graphene.Schema(query=Query)
示例11: test_mongoengine_interface
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_mongoengine_interface():
assert issubclass(Node, Interface)
assert issubclass(Node, Node)
示例12: test_should_query_list
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_should_query_list():
r1 = Reporter(last_name="ABA")
r1.save()
r2 = Reporter(last_name="Griffin")
r2.save()
class ReporterType(DjangoObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
class Query(graphene.ObjectType):
all_reporters = graphene.List(ReporterType)
debug = graphene.Field(DjangoDebug, name="__debug")
def resolve_all_reporters(self, info, **args):
return Reporter.objects.all()
query = """
query ReporterQuery {
allReporters {
lastName
}
__debug {
sql {
rawSql
}
}
}
"""
expected = {
"allReporters": [{"lastName": "ABA"}, {"lastName": "Griffin"}],
"__debug": {"sql": [{"rawSql": str(Reporter.objects.all().query)}]},
}
schema = graphene.Schema(query=Query)
result = schema.execute(
query, context_value=context(), middleware=[DjangoDebugMiddleware()]
)
assert not result.errors
assert result.data == expected
示例13: test_should_manytomany_convert_connectionorlist_connection
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_should_manytomany_convert_connectionorlist_connection():
class A(DjangoObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
graphene_field = convert_django_field(
Reporter._meta.local_many_to_many[0], A._meta.registry
)
assert isinstance(graphene_field, graphene.Dynamic)
dynamic_field = graphene_field.get_type()
assert isinstance(dynamic_field, ConnectionField)
assert dynamic_field.type.of_type == A._meta.connection
示例14: test_filter_filterset_class_filter_fields_exception
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_filter_filterset_class_filter_fields_exception():
with pytest.raises(Exception):
class ReporterFilter(FilterSet):
class Meta:
model = Reporter
fields = ["first_name", "articles"]
class ReporterFilterNode(DjangoObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
filterset_class = ReporterFilter
filter_fields = ["first_name", "articles"]
示例15: test_filter_filterset_class_information_on_meta
# 需要导入模块: from graphene import relay [as 别名]
# 或者: from graphene.relay import Node [as 别名]
def test_filter_filterset_class_information_on_meta():
class ReporterFilter(FilterSet):
class Meta:
model = Reporter
fields = ["first_name", "articles"]
class ReporterFilterNode(DjangoObjectType):
class Meta:
model = Reporter
interfaces = (Node,)
filterset_class = ReporterFilter
field = DjangoFilterConnectionField(ReporterFilterNode)
assert_arguments(field, "first_name", "articles")
assert_not_orderable(field)