Python graphene 模块,Int() 实例源码

我们从Python开源项目中,提取了以下18个代码示例,用于说明如何使用graphene.Int()

项目:elizabeth-cloud    作者:wemake-services    | 项目源码 | 文件源码
def get_field_args(field):
    types = {
        str: graphene.String,
        bool: graphene.Boolean,
        int: graphene.Int,
        float: graphene.Float,
    }

    try:
        args = inspect.signature(field)
        result = {}
        for name, arg in args.parameters.items():
            if arg.default is not None:
                custom_type = types[type(arg.default)]
            else:
                custom_type = graphene.String

            result.update({name: custom_type()})
        return result
    except (KeyError, ValueError):
        return {}
项目:graphql-python-subscriptions    作者:hballard    | 项目源码 | 文件源码
def schema():
    class Query(graphene.ObjectType):
        test_string = graphene.String()

        def resolve_test_string(self, args, context, info):
            return 'works'

    # TODO: Implement case conversion for arg names
    class Subscription(graphene.ObjectType):
        test_subscription = graphene.String()
        test_context = graphene.String()
        test_filter = graphene.String(filterBoolean=graphene.Boolean())
        test_filter_multi = graphene.String(
            filterBoolean=graphene.Boolean(),
            a=graphene.String(),
            b=graphene.Int())
        test_channel_options = graphene.String()

        def resolve_test_subscription(self, args, context, info):
            return self

        def resolve_test_context(self, args, context, info):
            return context

        def resolve_test_filter(self, args, context, info):
            return 'good_filter' if args.get('filterBoolean') else 'bad_filter'

        def resolve_test_filter_multi(self, args, context, info):
            return 'good_filter' if args.get('filterBoolean') else 'bad_filter'

        def resolve_test_channel_options(self, args, context, info):
            return self

    return graphene.Schema(query=Query, subscription=Subscription)
项目:graphql-pynamodb    作者:yfilali    | 项目源码 | 文件源码
def convert_column_to_int_or_id(type, attribute, registry=None):
    if attribute.is_hash_key:
        return ID(description=attribute.attr_name, required=not attribute.null)

    return Int(description=attribute.attr_name, required=not attribute.null)
项目:graphql-pynamodb    作者:yfilali    | 项目源码 | 文件源码
def test_should_number_convert_int():
    assert_attribute_conversion(NumberAttribute(), graphene.Int)
项目:graphql-pynamodb    作者:yfilali    | 项目源码 | 文件源码
def connection_for_type(_type):
    class Connection(graphene.Connection):
        total_count = graphene.Int()

        class Meta:
            name = _type._meta.name + 'Connection'
            node = _type

        def resolve_total_count(self, args, context, info):
            return self.total_count if hasattr(self, "total_count") else len(self.edges)

    return Connection
项目:graphene-mongo    作者:joaovitorsilvestre    | 项目源码 | 文件源码
def convert_fields(attrs_mongo_doc):
    """ Return a tuple od dicts,
    @param attrs_mongo_doc: dict of attributes of the mongoengine.Document, that is accessible by Document._fields     
    fields: is the pure fields, key is the name of field, and values is the repective graphene field
    fields_mutation: is the fields that is used in mutation, that will go direct in args of mutation
    operators_mutation: is the fields that user set values to be saved on document
    operators_single: is the fields with operators that will be in the query for a single result
    operators_list: same of operators single, but these are avaliable only for query of lists
    """

    fields, fields_mutation, operators_mutation, operators_single = {}, {}, {}, {}

    for f_name, mongo_field in attrs_mongo_doc.items():
        field = RelationMongoGraphene(name=f_name, mongo_field=mongo_field)

        fields[f_name] = field.graphene
        operators_single.update(field.operators)
        fields_mutation[f_name] = field.mutation
        if not isinstance(mongo_field, ObjectIdField):
            operators_mutation[f_name] = field.mutation

    operators_list = operators_single.copy()
    operators_single['skip'] = graphene.Int()

    operators_list.update({p: graphene.Int() for p in special_query_parameters})

    return fields, fields_mutation, operators_mutation, operators_single, operators_list
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def convert_form_field_to_int(field):
    return Int(description=field.help_text, required=field.required)
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_positive_integer_convert_int():
    assert_conversion(models.PositiveIntegerField, graphene.Int)
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_positive_small_convert_int():
    assert_conversion(models.PositiveSmallIntegerField, graphene.Int)
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_small_integer_convert_int():
    assert_conversion(models.SmallIntegerField, graphene.Int)
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_big_integer_convert_int():
    assert_conversion(models.BigIntegerField, graphene.Int)
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_integer_convert_int():
    assert_conversion(forms.IntegerField, graphene.Int)
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_integer_convert_int():
    assert_conversion(serializers.IntegerField, graphene.Int)
项目:graphene-django    作者:graphql-python    | 项目源码 | 文件源码
def test_should_list_convert_to_list():
    class StringListField(serializers.ListField):
        child = serializers.CharField()

    field_a = assert_conversion(
        serializers.ListField,
        graphene.List,
        child=serializers.IntegerField(min_value=0, max_value=100)
    )

    assert field_a.of_type == graphene.Int

    field_b = assert_conversion(StringListField, graphene.List)

    assert field_b.of_type == graphene.String
项目:dbas    作者:hhucn    | 项目源码 | 文件源码
def plural():
        return graphene.List(StatementGraph, is_startpoint=graphene.Boolean(), issue_uid=graphene.Int())
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def __init__(self, type, transform_edges=None, *args, **kwargs):
        super(NdbConnectionField, self).__init__(
            type,
            *args,
            keys_only=Boolean(),
            batch_size=Int(),
            page_size=Int(),
            **kwargs
        )

        self.transform_edges = transform_edges
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def convert_ndb_int_property(ndb_prop, registry=None):
    return convert_ndb_scalar_property(Int, ndb_prop)
项目:graphene-gae    作者:graphql-python    | 项目源码 | 文件源码
def testIntProperty_shouldConvertToString(self):
        self.__assert_conversion(ndb.IntegerProperty, graphene.Int)