當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。