當前位置: 首頁>>代碼示例>>Python>>正文


Python relay.Node方法代碼示例

本文整理匯總了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) 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:25,代碼來源:test_fields.py

示例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
    ) 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:20,代碼來源:test_fields.py

示例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) 
開發者ID:yfilali,項目名稱:graphql-pynamodb,代碼行數:5,代碼來源:test_types.py

示例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 
開發者ID:yfilali,項目名稱:graphql-pynamodb,代碼行數:13,代碼來源:test_converter.py

示例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) 
開發者ID:yfilali,項目名稱:graphql-pynamodb,代碼行數:12,代碼來源:test_converter.py

示例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) 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:32,代碼來源:test_benchmark.py

示例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) 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:13,代碼來源:test_converter.py

示例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 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:15,代碼來源:test_converter.py

示例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 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:15,代碼來源:test_converter.py

示例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) 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:32,代碼來源:test_batching.py

示例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) 
開發者ID:graphql-python,項目名稱:graphene-mongo,代碼行數:5,代碼來源:test_types.py

示例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 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:42,代碼來源:test_query.py

示例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 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:15,代碼來源:test_converter.py

示例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"] 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:16,代碼來源:test_fields.py

示例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) 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:17,代碼來源:test_fields.py


注:本文中的graphene.relay.Node方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。