You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to be able to apply a global filter for a model, for example by a published field.
See this example code and the comment inside the get_queryset method:
classCategory(models.Model):
name=models.CharField(max_length=128)
published=models.BooleanField(default=True)
classCategorySerializer(serializers.ModelSerializer):
classMeta:
model=CategoryclassCategoryType(DjangoSerializerType):
classMeta:
serializer_class=CategorySerializerpagination=LimitOffsetGraphqlPagination(default_limit=2, ordering='name')
@classmethoddefget_queryset(cls, queryset, info):
# This is one of graphene's documented approaches but it seems this library does not call this method.returnqueryset.filter(published=True)
classQuery(graphene.ObjectType):
category, categories=CategoryType.QueryFields()
What would be the recommended approach to achieve this using this library?
The text was updated successfully, but these errors were encountered:
I want to be able to apply a global filter for a model, for example by a published field.
See this example code and the comment inside the get_queryset method:
What would be the recommended approach to achieve this using this library?
The text was updated successfully, but these errors were encountered: