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


Python relay.ConnectionField方法代碼示例

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


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

示例1: type

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import ConnectionField [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: type

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

        _type = super(ConnectionField, self).type
        non_null = False
        if isinstance(_type, NonNull):
            _type = _type.of_type
            non_null = True
        assert issubclass(
            _type, DjangoObjectType
        ), "DjangoConnectionField only accepts DjangoObjectType types"
        assert _type._meta.connection, "The type {} doesn't have a connection".format(
            _type.__name__
        )
        connection_type = _type._meta.connection
        if non_null:
            return NonNull(connection_type)
        return connection_type 
開發者ID:graphql-python,項目名稱:graphene-django,代碼行數:20,代碼來源:fields.py

示例3: test_issue

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import ConnectionField [as 別名]
def test_issue():
    class Query(graphene.ObjectType):
        things = relay.ConnectionField(MyUnion)

    with raises(Exception) as exc_info:
        graphene.Schema(query=Query)

    assert str(exc_info.value) == (
        "Query fields cannot be resolved."
        " IterableConnectionField type has to be a subclass of Connection."
        ' Received "MyUnion".'
    ) 
開發者ID:graphql-python,項目名稱:graphene,代碼行數:14,代碼來源:test_356.py

示例4: type

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

        _type = super(ConnectionField, self).type
        assert issubclass(
            _type, MongoengineObjectType
        ), "MongoengineConnectionField only accepts MongoengineObjectType types"
        assert _type._meta.connection, "The type {} doesn't have a connection".format(
            _type.__name__
        )
        return _type._meta.connection 
開發者ID:graphql-python,項目名稱:graphene-mongo,代碼行數:13,代碼來源:fields.py

示例5: test_should_manytomany_convert_connectionorlist_connection

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import ConnectionField [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

示例6: _field_args

# 需要導入模塊: from graphene import relay [as 別名]
# 或者: from graphene.relay import ConnectionField [as 別名]
def _field_args(self, items):
        def is_filterable(k):
            """
            Remove complex columns from input args at this moment.

            Args:
                k (str): field name.
            Returns:
                bool
            """

            if not hasattr(self.model, k):
                return False
            if isinstance(getattr(self.model, k), property):
                return False
            try:
                converted = convert_mongoengine_field(
                    getattr(self.model, k), self.registry
                )
            except MongoEngineConversionError:
                return False
            if isinstance(converted, (ConnectionField, Dynamic)):
                return False
            if callable(getattr(converted, "type", None)) and isinstance(
                converted.type(),
                (
                    FileFieldType,
                    PointFieldType,
                    MultiPolygonFieldType,
                    graphene.Union,
                    PolygonFieldType,
                ),
            ):
                return False
            if isinstance(converted, (graphene.List)) and issubclass(
                getattr(converted, "_of_type", None), graphene.Union
            ):
                return False

            return True

        def get_filter_type(_type):
            """
            Returns the scalar type.
            """
            if isinstance(_type, Structure):
                return get_filter_type(_type.of_type)
            return _type()

        return {k: get_filter_type(v.type) for k, v in items if is_filterable(k)} 
開發者ID:graphql-python,項目名稱:graphene-mongo,代碼行數:52,代碼來源:fields.py


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