I have a Query:
class Query(object):
all_articles = graphene.List(ArticleType)
category_articles = graphene.List(ArticleType, category = graphene.String())
def resolve_all_articles(self, info, **kwargs):
return Article.objects.all()
def resolve_article_by_category(self, info, **kwargs):
category = kwargs.get('category')
return Article.objects.get(category = category)
And I want to get all articles by specific category. I try to make such a request:
query {
categoryArticles(category: "SPORT") {
title
}
}
But it returns me:
{
"data": {
"categoryArticles": null
}
}
Does somebody know what I do wrong or how to get articles by specific category? I will be very grateful if somebody can help. Thanks!
Was long time ago, but what helped is as @xadm
mentioned documantation link in the comments.
docs.graphene-python.org/projects/django/en/latest/filtering