简体   繁体   English

如何在python graphene中处理带参数的查询

[英]How to handle query with parameter in python graphene

class ProductQuery(graphene.ObjectType):
    products = graphene.List(Product)

    def resolve_products(self, info):
        return get_all_products()

Above are my code for query all product with no param.以上是我查询所有没有参数的产品的代码。 What is I want to query product by manufacture_id?我想通过manufacturer_id查询什么? How to do I do the resolver?我该如何做解析器?

There is no document on their official site .他们的官方网站上没有文件。

class ProductQuery(graphene.ObjectType):
  products = graphene.List(Product, id=graphene.Int())

  def resolve_products(self, info, id):
    return Product.objects.filter_by(manufacture_id__exact=id)

You have to add the parameter you want to query by.您必须添加要查询的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何正确处理石墨烯错误? - How to handle properly handle graphene error? graphQL 和石墨烯:如何使用石墨烯从 graphQL 查询中提取信息? - graphQL and graphene: How to extract information from a graphQL query using graphene? 如何在 python 中使用石墨烯-pydantic 和石墨烯的子类中的 pydantic 模型? - How to use pydantic models in subclass with graphene-pydantic and graphene in python? Graphene-django-如何捕获查询的响应? - Graphene-django - How to catch response of query? 如何在python(graphene?)中的GraphQL中指定(导入?)方案? - How to specify (import?) scheme in GraphQL in python (graphene?)? 如何在 Graphene Python 突变中设置 cookie? - How to set cookies in Graphene Python mutation? 如何在石墨烯mongo python中更新EmbeddedDocument的字段 - How to update field for EmbeddedDocument in graphene mongo python python - fastapi - 石墨烯 - sql 炼金术 - 无法查询关系列 - python - fastapi - graphene - sql alchemy - not able to query relationship column Python argparse:如何处理MacOSX的-psn参数 - Python argparse: how to handle MacOSX `-psn` parameter Flask / SqlAlchemy / Graphene - 如何从数据库查询对象并更改值? - Flask / SqlAlchemy / Graphene - how to query an object from DB and change value?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM