当前位置: 首页>>代码示例>>Python>>正文


Python graphene.Dynamic方法代码示例

本文整理汇总了Python中graphene.Dynamic方法的典型用法代码示例。如果您正苦于以下问题:Python graphene.Dynamic方法的具体用法?Python graphene.Dynamic怎么用?Python graphene.Dynamic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graphene的用法示例。


在下文中一共展示了graphene.Dynamic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: convert_local_structured_property

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def convert_local_structured_property(ndb_structured_property, registry=None):
    is_required = ndb_structured_property._required
    is_repeated = ndb_structured_property._repeated
    model = ndb_structured_property._modelclass
    name = ndb_structured_property._code_name

    def dynamic_type():
        _type = registry.get_type_for_model(model)
        if not _type:
            return None

        if is_repeated:
            _type = List(_type)

        if is_required:
            _type = NonNull(_type)

        return Field(_type)

    field = Dynamic(dynamic_type)
    return ConversionResult(name=name, field=field) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:23,代码来源:converter.py

示例2: convert_lazy_field_to_dynamic

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def convert_lazy_field_to_dynamic(field, registry=None):
    model = field.document_type

    def lazy_resolver(root, *args, **kwargs):
        if getattr(root, field.name or field.db_name):
            return getattr(root, field.name or field.db_name).fetch()

    def dynamic_type():
        _type = registry.get_type_for_model(model)
        if not _type:
            return None
        return graphene.Field(
            _type,
            resolver=lazy_resolver,
            description=get_field_description(field, registry),
        )

    return graphene.Dynamic(dynamic_type) 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:20,代码来源:converter.py

示例3: test_should_self_reference_convert_dynamic

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_self_reference_convert_dynamic():
    class P(MongoengineObjectType):
        class Meta:
            model = Player
            interfaces = (graphene.Node,)

    dynamic_field = convert_mongoengine_field(
        Player._fields["opponent"], P._meta.registry
    )
    assert isinstance(dynamic_field, graphene.Dynamic)
    graphene_type = dynamic_field.get_type()
    assert isinstance(graphene_type, graphene.Field)
    assert graphene_type.type == P

    graphene_field = convert_mongoengine_field(
        Player._fields["players"], P._meta.registry
    )
    assert isinstance(graphene_field, MongoengineConnectionField) 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:20,代码来源:test_converter.py

示例4: test_should_manytomany_convert_connectionorlist_list

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_manytomany_convert_connectionorlist_list():
    class A(DjangoObjectType):
        class Meta:
            model = Reporter

    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, graphene.Field)
    # A NonNull List of NonNull A ([A!]!)
    # https://github.com/graphql-python/graphene-django/issues/448
    assert isinstance(dynamic_field.type, NonNull)
    assert isinstance(dynamic_field.type.of_type, graphene.List)
    assert isinstance(dynamic_field.type.of_type.of_type, NonNull)
    assert dynamic_field.type.of_type.of_type.of_type == A 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:19,代码来源:test_converter.py

示例5: convert_relationship_to_dynamic

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def convert_relationship_to_dynamic(type, attribute, registry=None):
    def dynamic_type():
        _type = registry.get_type_for_model(attribute.model)
        if not _type:
            return None

        if isinstance(attribute, OneToOne):
            return Field(_type)

        if isinstance(attribute, OneToMany):
            if _type._meta.connection:
                return PynamoConnectionField(_type)
            return Field(List(_type))

    return Dynamic(dynamic_type) 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:17,代码来源:converter.py

示例6: test_should_onetoone_convert_field

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [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

示例7: test_should_onetomany_convert_nonnode_field

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_onetomany_convert_nonnode_field():
    class A(PynamoObjectType):
        class Meta:
            model = Article

    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, graphene.Field)
    assert graphene_type.type == graphene.List(A) 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:12,代码来源:test_converter.py

示例8: test_should_onetomany_none_for_unknown_type

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_onetomany_none_for_unknown_type():
    class ModelA(Model):
        pass

    class ModelB(Model):
        a = OneToMany(ModelA)

    class A(PynamoObjectType):
        class Meta:
            model = ModelB

    dynamic_field = convert_pynamo_attribute(ModelB.a, ModelB.a, A._meta.registry)
    assert isinstance(dynamic_field, Dynamic)
    assert dynamic_field.get_type() is None 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:16,代码来源:test_converter.py

示例9: test_should_onetomany_convert_field

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [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

示例10: test_should_manytomany_convert_connectionorlist

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_manytomany_convert_connectionorlist():
    class A(SQLAlchemyObjectType):
        class Meta:
            model = Article

    dynamic_field = convert_sqlalchemy_relationship(
        Reporter.pets.property, A, default_connection_field_factory, True, 'orm_field_name',
    )
    assert isinstance(dynamic_field, graphene.Dynamic)
    assert not dynamic_field.get_type() 
开发者ID:graphql-python,项目名称:graphene-sqlalchemy,代码行数:12,代码来源:test_converter.py

示例11: test_should_manytomany_convert_connectionorlist_list

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_manytomany_convert_connectionorlist_list():
    class A(SQLAlchemyObjectType):
        class Meta:
            model = Pet

    dynamic_field = convert_sqlalchemy_relationship(
        Reporter.pets.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 isinstance(graphene_type.type, graphene.List)
    assert graphene_type.type.of_type == A 
开发者ID:graphql-python,项目名称:graphene-sqlalchemy,代码行数:15,代码来源:test_converter.py

示例12: test_should_manytomany_convert_connectionorlist_connection

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [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

示例13: test_should_manytoone_convert_connectionorlist

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_manytoone_convert_connectionorlist():
    class A(SQLAlchemyObjectType):
        class Meta:
            model = Article

    dynamic_field = convert_sqlalchemy_relationship(
        Reporter.pets.property, A, default_connection_field_factory, True, 'orm_field_name',
    )
    assert isinstance(dynamic_field, graphene.Dynamic)
    assert not dynamic_field.get_type() 
开发者ID:graphql-python,项目名称:graphene-sqlalchemy,代码行数:12,代码来源:test_converter.py

示例14: test_should_manytoone_convert_connectionorlist_list

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [as 别名]
def test_should_manytoone_convert_connectionorlist_list():
    class A(SQLAlchemyObjectType):
        class Meta:
            model = Reporter

    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,代码行数:14,代码来源:test_converter.py

示例15: test_should_onetoone_convert_field

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Dynamic [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


注:本文中的graphene.Dynamic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。