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