class ProductQuery(graphene.ObjectType):
products = graphene.List(Product)
def resolve_products(self, info):
return get_all_products()
上面是我的代码,用于查询所有不带参数的产品。我想按制造商ID查询产品吗?我该怎么办解析器?
their official site上没有文档。
最佳答案
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)
关于python - 如何在python graphene中使用参数处理查询,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51885554/