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


Python graphene.Boolean方法代码示例

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


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

示例1: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def __init__(self, ndb_key_prop, graphql_type_name, *args, **kwargs):
        self.__ndb_key_prop = ndb_key_prop
        self.__graphql_type_name = graphql_type_name
        is_repeated = ndb_key_prop._repeated
        is_required = ndb_key_prop._required

        _type = String
        if is_repeated:
            _type = List(_type)

        if is_required:
            _type = NonNull(_type)

        kwargs['args'] = {
            'ndb': Argument(Boolean, False, description="Return an NDB id (key.id()) instead of a GraphQL global id")
        }

        super(NdbKeyStringField, self).__init__(_type, *args, **kwargs) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:20,代码来源:fields.py

示例2: convert_ndb_boolean_property

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def convert_ndb_boolean_property(ndb_prop, registry=None):
    return convert_ndb_scalar_property(Boolean, ndb_prop) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:4,代码来源:converter.py

示例3: testBoolProperty_shouldConvertToString

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def testBoolProperty_shouldConvertToString(self):
        self.__assert_conversion(ndb.BooleanProperty, graphene.Boolean) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:4,代码来源:test_converter.py

示例4: test_context_lifetime

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def test_context_lifetime(gql):
    """Check that `info.context` holds data during the connection."""

    # Store ids of `info.context.scope` objects to check them later.
    run_log: List[bool] = []

    print("Setup GraphQL backend and initialize GraphQL client.")

    # pylint: disable=no-self-use
    class Query(graphene.ObjectType):
        """Root GraphQL query."""

        ok = graphene.Boolean()

        def resolve_ok(self, info):
            """Store `info.context.scope` id."""

            run_log.append("fortytwo" in info.context)
            if "fortytwo" in info.context:
                assert info.context.fortytwo == 42, "Context has delivered wrong data!"
            info.context.fortytwo = 42

            return True

    for _ in range(2):
        print("Make connection and perform query and close connection.")
        client = gql(query=Query, consumer_attrs={"strict_ordering": True})
        await client.connect_and_init()
        for _ in range(2):
            await client.send(msg_type="start", payload={"query": "{ ok }"})
            await client.receive(assert_type="data")
            await client.receive(assert_type="complete")
        await client.finalize()

    # Expected run log: [False, True, False, True].
    assert run_log[2] is False, "Context preserved between connections!"
    assert run_log[0:2] == [False, True], "Context is not preserved in a connection!"
    assert run_log[2:4] == [False, True], "Context is not preserved in a connection!" 
开发者ID:datadvance,项目名称:DjangoChannelsGraphqlWs,代码行数:40,代码来源:test_context.py

示例5: test_custom_filter_field_type

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def test_custom_filter_field_type():
    filter_fields = deepcopy(UserFilter._meta.fields)

    assert 'is_admin' in filter_fields
    is_rich = filter_fields['is_admin']
    assert isinstance(is_rich, graphene.InputField)
    assert is_rich.type is graphene.Boolean
    del filter_fields['is_admin'] 
开发者ID:art1415926535,项目名称:graphene-sqlalchemy-filter,代码行数:10,代码来源:test_filter_set.py

示例6: test_meta_without_model

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def test_meta_without_model():
    ok = {'field', 'and', 'or', 'not'}

    class F1(FilterSet):
        field = graphene.Boolean()

        @staticmethod
        def field_filter(info, query, value):
            return True

    filter_fields = set(F1._meta.fields)

    assert filter_fields == ok

    class F2(F1):
        class Meta:
            fields = {}

    filter_fields = set(F2._meta.fields)
    assert filter_fields == ok

    with pytest.raises(AttributeError, match='Model not specified'):

        class F3(F1):
            class Meta:
                fields = {'username': [...]} 
开发者ID:art1415926535,项目名称:graphene-sqlalchemy-filter,代码行数:28,代码来源:test_filter_set.py

示例7: convert_column_to_boolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def convert_column_to_boolean(type, attribute, registry=None):
    return Boolean(description=attribute.attr_name, required=not attribute.null) 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:4,代码来源:converter.py

示例8: test_should_boolean_convert_boolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def test_should_boolean_convert_boolean():
    assert_attribute_conversion(BooleanAttribute(), graphene.Boolean) 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:4,代码来源:test_converter.py

示例9: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def __init__(self):
        self._typeMap = {}
        self.Field = create_registry_field(self)
        self.Argument = create_registry_argument(self)
        self.List = create_registry_list(self)
        self.NonNull = create_registry_nonnull(self)
        registering_metaclass = create_registering_metaclass(self)
        self.Union = create_union(registering_metaclass, self)
        self.Enum = create_enum(registering_metaclass)
        self.Mutation = graphene.Mutation

        # Not looping over GRAPHENE_TYPES in order to not fool lint
        self.ObjectType = create_registering_class(graphene.ObjectType, registering_metaclass)
        self.InputObjectType = create_registering_class(
            graphene.InputObjectType, registering_metaclass
        )
        self.Interface = create_registering_class(graphene.Interface, registering_metaclass)
        self.Scalar = create_registering_class(graphene.Scalar, registering_metaclass)

        # Not looping over GRAPHENE_BUILTINS in order to not fool lint
        self.String = graphene.String
        self.addType(graphene.String)
        self.Int = graphene.Int
        self.addType(graphene.Int)
        self.Float = graphene.Float
        self.addType(graphene.Float)
        self.Boolean = graphene.Boolean
        self.addType(graphene.Boolean)
        self.ID = graphene.ID
        self.addType(graphene.ID)
        self.GenericScalar = GenericScalar
        self.addType(GenericScalar) 
开发者ID:dagster-io,项目名称:dagster,代码行数:34,代码来源:dauphin_registry.py

示例10: test_should_boolean_convert_boolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def test_should_boolean_convert_boolean():
    assert get_field(types.Boolean()).type == graphene.Boolean 
开发者ID:graphql-python,项目名称:graphene-sqlalchemy,代码行数:4,代码来源:test_converter.py

示例11: convert_field_to_boolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def convert_field_to_boolean(field, registry=None):
    return graphene.Boolean(
        description=get_field_description(field, registry), required=field.required
    ) 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:6,代码来源:converter.py

示例12: test_should_boolean_convert_boolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def test_should_boolean_convert_boolean():
    assert_conversion(mongoengine.BooleanField, graphene.Boolean) 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:4,代码来源:test_converter.py

示例13: convert_form_field_to_boolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def convert_form_field_to_boolean(field):
    return Boolean(description=field.help_text, required=field.required) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:converter.py

示例14: convert_form_field_to_nullboolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def convert_form_field_to_nullboolean(field):
    return Boolean(description=field.help_text) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:converter.py

示例15: test_should_boolean_convert_boolean

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def test_should_boolean_convert_boolean():
    assert_conversion(serializers.BooleanField, graphene.Boolean) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:test_field_converter.py


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