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


Python graphene.Int方法代码示例

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


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

示例1: to_graphql_fields

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def to_graphql_fields(self):
        return {
            self.limit_query_param: Int(
                default_value=self.default_limit,
                description="Number of results to return per page. Default "
                "'default_limit': {}, and 'max_limit': {}".format(
                    self.default_limit, self.max_limit
                ),
            ),
            self.offset_query_param: Int(
                description="The initial index from which to return the results. Default: 0"
            ),
            self.ordering_param: String(
                description="A string or comma delimited string values that indicate the "
                "default ordering when obtaining lists of objects."
            ),
        } 
开发者ID:eamigo86,项目名称:graphene-django-extras,代码行数:19,代码来源:pagination.py

示例2: ImageQueryMixin

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def ImageQueryMixin():
    class Mixin:
        images = graphene.List(Image)
        image = graphene.Field(Image,
                               id=graphene.Int(required=True))

        def resolve_images(self, info: ResolveInfo):
            return with_collection_permissions(
                info.context,
                gql_optimizer.query(
                    wagtailImage.objects.all(),
                    info
                )
            )

        def resolve_image(self, info: ResolveInfo, id: int):
            image = with_collection_permissions(
                info.context,
                gql_optimizer.query(
                    wagtailImage.objects.filter(id=id),
                    info
                )
            ).first()
            return image
    return Mixin 
开发者ID:tr11,项目名称:wagtail-graphql,代码行数:27,代码来源:images.py

示例3: DocumentQueryMixin

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def DocumentQueryMixin():
    class Mixin:
        documents = graphene.List(Document)
        document = graphene.Field(Document,
                                  id=graphene.Int(required=True))

        def resolve_documents(self, info: ResolveInfo):
            return with_collection_permissions(
                info.context,
                gql_optimizer.query(
                    wagtailDocument.objects.all(),
                    info
                )
            )

        def resolve_document(self, info: ResolveInfo, id: int):
            doc = with_collection_permissions(
                info.context,
                gql_optimizer.query(
                    wagtailDocument.objects.filter(id=id),
                    info
                )
            ).first()
            return doc
    return Mixin 
开发者ID:tr11,项目名称:wagtail-graphql,代码行数:27,代码来源:documents.py

示例4: connection_factory

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def connection_factory(cls, node):
		name = node.__name__ + 'Connection'
		if name in cls.__connection_types:
			return cls.__connection_types[name]
		connection_type = type(
			node.__name__ + 'Connection',
			(graphene.relay.Connection,),
			{
				'Meta': type('Meta', (), {'node': node}),
				'total': graphene.Int()
			}
		)
		cls.__connection_types[name] = connection_type
		return connection_type 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:16,代码来源:database.py

示例5: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
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 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:13,代码来源:fields.py

示例6: convert_ndb_int_property

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

示例7: testIntProperty_shouldConvertToString

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

示例8: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def __init__(
        self, _type, ordering="-created", cursor_query_param="cursor", *args, **kwargs
    ):
        kwargs.setdefault("args", {})

        self.page_size = graphql_api_settings.DEFAULT_PAGE_SIZE
        self.page_size_query_param = "page_size" if not self.page_size else None
        self.cursor_query_param = cursor_query_param
        self.ordering = ordering
        self.cursor_query_description = "The pagination cursor value."
        self.page_size_query_description = "Number of results to return per page."

        kwargs[self.cursor_query_param] = NonNull(
            String, description=self.cursor_query_description
        )

        if self.page_size_query_param:
            if not self.page_size:
                kwargs[self.page_size_query_param] = NonNull(
                    Int, description=self.page_size_query_description
                )
            else:
                kwargs[self.page_size_query_param] = Int(
                    description=self.page_size_query_description
                )

        super(CursorPaginationField, self).__init__(List(_type), *args, **kwargs) 
开发者ID:eamigo86,项目名称:graphene-django-extras,代码行数:29,代码来源:fields.py

示例9: connection_for_type

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def connection_for_type(_type):
    class Connection(graphene.relay.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 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:14,代码来源:utils.py

示例10: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [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

示例11: convert_column_to_int_or_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def convert_column_to_int_or_id(type, column, registry=None):
    if column.primary_key or column.foreign_keys:
        return graphene.ID(
            description=get_column_doc(column),
            required=not (is_column_nullable(column)),
        )
    else:
        return graphene.Int(
            description=get_column_doc(column),
            required=not (is_column_nullable(column)),
        ) 
开发者ID:briancappello,项目名称:flask-unchained,代码行数:13,代码来源:object_types.py

示例12: convert_field_to_int

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

示例13: test_should_custom_kwargs

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import Int [as 别名]
def test_should_custom_kwargs(fixtures):
    class Query(graphene.ObjectType):

        editors = graphene.List(types.EditorType, first=graphene.Int())

        def resolve_editors(self, *args, **kwargs):
            editors = models.Editor.objects()
            if "first" in kwargs:
                editors = editors[: kwargs["first"]]
            return list(editors)

    query = """
        query EditorQuery {
            editors(first: 2) {
                firstName,
                lastName
            }
        }
    """
    expected = {
        "editors": [
            {"firstName": "Penny", "lastName": "Hardaway"},
            {"firstName": "Grant", "lastName": "Hill"},
        ]
    }
    schema = graphene.Schema(query=Query)
    result = schema.execute(query)
    assert not result.errors
    assert result.data == expected 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:31,代码来源:test_query.py

示例14: test_sould_int_convert_int

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

示例15: test_sould_long_convert_int

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


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