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


Python relay.Connection方法代碼示例

本文整理匯總了Python中graphene.relay.Connection方法的典型用法代碼示例。如果您正苦於以下問題:Python relay.Connection方法的具體用法?Python relay.Connection怎麽用?Python relay.Connection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在graphene.relay的用法示例。


在下文中一共展示了relay.Connection方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: type

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import Connection [as 別名]
def type(self):
        from .types import SQLAlchemyObjectType

        _type = super(ConnectionField, self).type
        nullable_type = get_nullable_type(_type)
        if issubclass(nullable_type, Connection):
            return _type
        assert issubclass(nullable_type, SQLAlchemyObjectType), (
            "SQLALchemyConnectionField only accepts SQLAlchemyObjectType types, not {}"
        ).format(nullable_type.__name__)
        assert (
            nullable_type.connection
        ), "The type {} doesn't have a connection".format(
            nullable_type.__name__
        )
        assert _type == nullable_type, (
            "Passing a SQLAlchemyObjectType instance is deprecated. "
            "Pass the connection type instead accessible via SQLAlchemyObjectType.connection"
        )
        return nullable_type.connection 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:22,代碼來源:fields.py

示例2: __init__

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import Connection [as 別名]
def __init__(self, type, *args, **kwargs):
        nullable_type = get_nullable_type(type)
        if "sort" not in kwargs and issubclass(nullable_type, Connection):
            # Let super class raise if type is not a Connection
            try:
                kwargs.setdefault("sort", nullable_type.Edge.node._type.sort_argument())
            except (AttributeError, TypeError):
                raise TypeError(
                    'Cannot create sort argument for {}. A model is required. Set the "sort" argument'
                    " to None to disabling the creation of the sort query argument".format(
                        nullable_type.__name__
                    )
                )
        elif "sort" in kwargs and kwargs["sort"] is None:
            del kwargs["sort"]
        super(SQLAlchemyConnectionField, self).__init__(type, *args, **kwargs) 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:18,代碼來源:fields.py

示例3: test_nonnull_sqlalachemy_connection

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import Connection [as 別名]
def test_nonnull_sqlalachemy_connection():
    field = SQLAlchemyConnectionField(NonNull(Pet.connection))
    assert isinstance(field.type, NonNull)
    assert issubclass(field.type.of_type, Connection)
    assert field.type.of_type._meta.node is Pet 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:7,代碼來源:test_fields.py

示例4: test_required_sqlalachemy_connection

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import Connection [as 別名]
def test_required_sqlalachemy_connection():
    field = SQLAlchemyConnectionField(Pet.connection, required=True)
    assert isinstance(field.type, NonNull)
    assert issubclass(field.type.of_type, Connection)
    assert field.type.of_type._meta.node is Pet 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:7,代碼來源:test_fields.py

示例5: test_sort_init_raises

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import Connection [as 別名]
def test_sort_init_raises():
    with pytest.raises(TypeError, match="Cannot create sort"):
        SQLAlchemyConnectionField(Connection) 
開發者ID:graphql-python,項目名稱:graphene-sqlalchemy,代碼行數:5,代碼來源:test_fields.py


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