[英]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.