class ProductQuery(graphene.ObjectType):
products = graphene.List(Product)
def resolve_products(self, info):
return get_all_products()
以上是我用于查询所有不带参数的产品的代码。我要按制造商ID查询产品什么?我该怎么办解析器?
their official site上没有文档。
答案 0 :(得分:0)
class ProductQuery(graphene.ObjectType):
products = graphene.List(Product, id=graphene.Int())
def resolve_products(self, info, id):
return Product.objects.filter(manufacture_id__exact=id)