Reputation: 14554
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? How to do I do the resolver?
There is no document on their official site.
Upvotes: 6
Views: 4442
Reputation: 101
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.
Upvotes: 7