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


Python graphene.List方法代码示例

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


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

示例1: batch_multiresult

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def batch_multiresult(
    context: Mapping[str, Any],
    conn: SAConnection,
    query: sa.sql.Select,
    obj_type: Type[_GenericSQLBasedGQLObject],
    key_list: Iterable[_Key],
    key_getter: Callable[[RowProxy], _Key],
) -> Sequence[Sequence[_GenericSQLBasedGQLObject]]:
    """
    A batched query adaptor for (key -> [item]) resolving patterns.
    """
    objs_per_key: Dict[_Key, List[_GenericSQLBasedGQLObject]]
    objs_per_key = collections.OrderedDict()
    for key in key_list:
        objs_per_key[key] = list()
    async for row in conn.execute(query):
        objs_per_key[key_getter(row)].append(
            obj_type.from_row(context, row)
        )
    return [*objs_per_key.values()] 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:22,代码来源:base.py

示例2: __init__

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

示例3: convert_local_structured_property

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def convert_local_structured_property(ndb_structured_property, registry=None):
    is_required = ndb_structured_property._required
    is_repeated = ndb_structured_property._repeated
    model = ndb_structured_property._modelclass
    name = ndb_structured_property._code_name

    def dynamic_type():
        _type = registry.get_type_for_model(model)
        if not _type:
            return None

        if is_repeated:
            _type = List(_type)

        if is_required:
            _type = NonNull(_type)

        return Field(_type)

    field = Dynamic(dynamic_type)
    return ConversionResult(name=name, field=field) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:23,代码来源:converter.py

示例4: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def __init__(self, _type, paginator_instance, *args, **kwargs):
        kwargs.setdefault("args", {})

        self.paginator_instance = paginator_instance

        kwargs.update(self.paginator_instance.to_graphql_fields())
        kwargs.update(
            {
                "description": "{} list, paginated by {}".format(
                    _type._meta.model.__name__, paginator_instance.__name__
                )
            }
        )

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

示例5: test_conjunction_filter_field_types

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def test_conjunction_filter_field_types():
    filter_fields = deepcopy(UserFilter._meta.fields)

    for op in [UserFilter.AND, UserFilter.OR]:
        assert op in filter_fields
        assert isinstance(filter_fields[op], graphene.InputField)

        input_field = filter_fields[op].type
        assert isinstance(input_field, graphene.List)

        input_field_of_type = input_field.of_type
        assert isinstance(input_field_of_type, graphene.NonNull)

        non_null_input_field_of_type = input_field_of_type.of_type
        assert non_null_input_field_of_type is UserFilter

        del filter_fields[op] 
开发者ID:art1415926535,项目名称:graphene-sqlalchemy-filter,代码行数:19,代码来源:test_filter_set.py

示例6: sort_argument_for_model

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def sort_argument_for_model(cls, has_default=True):
    """Get a Graphene Argument for sorting the given model class.

    This is deprecated, please use object_type.sort_argument() instead.
    """
    warnings.warn(
        "sort_argument_for_model() is deprecated;"
        " use object_type.sort_argument() instead.",
        DeprecationWarning,
        stacklevel=2,
    )

    from graphene import Argument, List
    from .enums import sort_enum_for_object_type

    enum = sort_enum_for_object_type(
        _deprecated_object_type_for_model(cls, None),
        get_symbol_name=_deprecated_default_symbol_name,
    )
    if not has_default:
        enum.default = None

    return Argument(List(enum), default_value=enum.default) 
开发者ID:graphql-python,项目名称:graphene-sqlalchemy,代码行数:25,代码来源:utils.py

示例7: resolve_background_jobs

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def resolve_background_jobs(self, info, **kwargs):
        """Method to return a all background jobs the system is aware of: Queued, Started, Finished, Failed.

        Returns:
            list(JobStatus)
        """
        job_dispatcher = Dispatcher()

        edges: List[str] = [j.job_key.key_str for j in job_dispatcher.all_jobs]
        cursors = [base64.b64encode(f"{str(cnt)}".encode('utf-8')) for cnt, x in enumerate(edges)]

        # Process slicing and cursor args
        lbc = ListBasedConnection(edges, cursors, kwargs)
        lbc.apply()

        edge_objs = []
        for edge, cursor in zip(lbc.edges, lbc.cursors):
            edge_objs.append(JobStatusConnection.Edge(node=JobStatus(edge), cursor=cursor))

        return JobStatusConnection(edges=edge_objs, page_info=lbc.page_info) 
开发者ID:gigantum,项目名称:gigantum-client,代码行数:22,代码来源:query.py

示例8: filter_args

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def filter_args(self):
        filter_args = dict()
        if self._type._meta.filter_fields:
            for field, filter_collection in self._type._meta.filter_fields.items():
                for each in filter_collection:
                    filter_type = getattr(
                        graphene,
                        str(self._type._meta.fields[field].type).replace("!", ""),
                    )

                    # handle special cases
                    advanced_filter_types = {
                        "in": graphene.List(filter_type),
                        "nin": graphene.List(filter_type),
                        "all": graphene.List(filter_type),
                    }

                    filter_type = advanced_filter_types.get(each, filter_type)
                    filter_args[field + "__" + each] = graphene.Argument(
                        type=filter_type
                    )

        return filter_args 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:25,代码来源:fields.py

示例9: test_should_manytomany_convert_connectionorlist_list

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def test_should_manytomany_convert_connectionorlist_list():
    class A(DjangoObjectType):
        class Meta:
            model = Reporter

    graphene_field = convert_django_field(
        Reporter._meta.local_many_to_many[0], A._meta.registry
    )
    assert isinstance(graphene_field, graphene.Dynamic)
    dynamic_field = graphene_field.get_type()
    assert isinstance(dynamic_field, graphene.Field)
    # A NonNull List of NonNull A ([A!]!)
    # https://github.com/graphql-python/graphene-django/issues/448
    assert isinstance(dynamic_field.type, NonNull)
    assert isinstance(dynamic_field.type.of_type, graphene.List)
    assert isinstance(dynamic_field.type.of_type.of_type, NonNull)
    assert dynamic_field.type.of_type.of_type.of_type == A 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:19,代码来源:test_converter.py

示例10: test_should_postgres_array_multiple_convert_list

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def test_should_postgres_array_multiple_convert_list():
    field = assert_conversion(
        ArrayField, graphene.List, ArrayField(models.CharField(max_length=100))
    )
    assert isinstance(field.type, graphene.NonNull)
    assert isinstance(field.type.of_type, graphene.List)
    assert isinstance(field.type.of_type.of_type, graphene.List)
    assert isinstance(field.type.of_type.of_type.of_type, graphene.NonNull)
    assert field.type.of_type.of_type.of_type.of_type == graphene.String

    field = assert_conversion(
        ArrayField,
        graphene.List,
        ArrayField(models.CharField(max_length=100, null=True)),
    )
    assert isinstance(field.type, graphene.NonNull)
    assert isinstance(field.type.of_type, graphene.List)
    assert isinstance(field.type.of_type.of_type, graphene.List)
    assert field.type.of_type.of_type.of_type == graphene.String 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:21,代码来源:test_converter.py

示例11: mutate

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def mutate(cls, _, info, __):
        logger.debug("agrs %s", info)
        post_schema = t.Dict({
            'title': t.String(min_length=2),
            'user_id': t.String(min_length=2),
            'content': t.String(min_length=2),
            t.Key('tags',
                  optional=True): t.List(t.String,
                                         min_length=1),
        })

        post_data = post_schema.check(info)
        user_id = post_data.pop('user_id')
        user = User.objects.get_or_404(id=user_id)
        post = Post(author=user, **post_data)
        post.save()
        return cls(post=construct(PostField, post)) 
开发者ID:msoedov,项目名称:flask-graphql-example,代码行数:19,代码来源:ql.py

示例12: query_owned_dotfiles

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def query_owned_dotfiles(
    conn: SAConnection,
    access_key: AccessKey,
) -> Tuple[List[Dotfile], int]:
    query = (sa.select([keypairs.c.dotfiles])
               .select_from(keypairs)
               .where(keypairs.c.access_key == access_key))
    packed_dotfile = await conn.scalar(query)
    rows = msgpack.unpackb(packed_dotfile)
    return rows, MAXIMUM_DOTFILE_SIZE - len(packed_dotfile) 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:12,代码来源:keypair.py

示例13: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def __init__(self, node, *args, **kwargs):
		if 'filter' not in kwargs:
			kwargs['filter'] = gql_misctypes.FilterInput()
		if 'sort' not in kwargs:
			kwargs['sort'] = graphene.List(gql_misctypes.SortInput)
		node = self.connection_factory(node)
		super(SQLAlchemyConnectionField, self).__init__(node, *args, **kwargs) 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:9,代码来源:database.py

示例14: convert_ndb_scalar_property

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def convert_ndb_scalar_property(graphene_type, ndb_prop, registry=None, **kwargs):
    kwargs['description'] = "%s %s property" % (ndb_prop._name, graphene_type)
    _type = graphene_type

    if ndb_prop._repeated:
        _type = List(_type)

    if ndb_prop._required:
        _type = NonNull(_type)

    return Field(_type, **kwargs) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:13,代码来源:converter.py

示例15: testQuery_onlyFields

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import List [as 别名]
def testQuery_onlyFields(self):
        Article(headline="h1", summary="s1").put()

        class ArticleType(NdbObjectType):
            class Meta:
                model = Article
                only_fields = ['headline']

        class QueryType(graphene.ObjectType):
            articles = graphene.List(ArticleType)

            def resolve_articles(self, info):
                return Article.query()

        schema = graphene.Schema(query=QueryType)
        query = '''
                    query ArticlesQuery {
                      articles { headline }
                    }
                '''

        result = schema.execute(query)

        self.assertIsNotNone(result.data)
        self.assertEqual(result.data['articles'][0]['headline'], 'h1')

        query = '''
                    query ArticlesQuery {
                      articles { headline, summary }
                    }
                '''
        result = schema.execute(query)

        self.assertIsNotNone(result.errors)
        self.assertTrue('Cannot query field "summary"' in result.errors[0].message) 
开发者ID:graphql-python,项目名称:graphene-gae,代码行数:37,代码来源:test_types.py


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