本文整理汇总了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)
示例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)
示例3: testBoolProperty_shouldConvertToString
# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Boolean [as 别名]
def testBoolProperty_shouldConvertToString(self):
self.__assert_conversion(ndb.BooleanProperty, graphene.Boolean)
示例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!"
示例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']
示例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': [...]}
示例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)
示例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)
示例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)
示例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
示例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
)
示例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)
示例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)
示例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)
示例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)