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