graphene-django-extras
graphene-django-extras copied to clipboard
How to filter QuerySet in DjangoSerializerType ?
I have articles. Each user must be read only their own articles. -> Articles.objects.filter(user=request.user)
class ArticleModelType(DjangoSerializerType):
class Meta:
filter_fields = {
'name': ['exact'],
'category': ['exact'],
'category__name': ['exact']
}
serializer_class = ArticleSerializer
class Query(graphene.ObjectType):
article, articles = ArticleModelType.QueryFields()
I still haven't found a place where I should put this QuerySet = Articles.objects.filter(user=request.user)