当前位置: 首页>>代码示例>>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;未经允许,请勿转载。