graphene-django-extras
graphene-django-extras copied to clipboard
filter_fields on Enum/ChoiceFields
The request is similar to https://github.com/graphql-python/graphene-django/issues/176.
I have a DjangoSerializerType
that I'm trying to set filter_fields
on its choice/enum field, however the enum field happens to be simply an String type.
class Movie(models.Model):
title = models.CharField()
genre = models.CharField(choices=(('a', 'A'), ('b', 'B'), ('c', 'C'),))
class MovieSerializer(serializers.ModelSerializer):
class Meta:
model = Movie
fields = '__all__'
class MovieType(DjangoSerializerType):
class Meta:
serializer_class = MovieSerializer
filter_fields = {
'title': ('exact', 'icontains', 'istartswith', ),
'genre': ('exact', ) # Genre should be Enum type, but it comes as String
}
Worth noting the genre is successfully displayed as Enum type when getting the data, but when doing query filtering it's always String.
When Filtering:
query {
movies(genre: "a") { # it's a string and not a type.
...
}
}
When retrieving:
query {
movies {
...
}
}
# Result
{
data: {
{"title": "Batman!", genre: "A"} # comes with value of Enum
}
}
Any idea how this can be resolved ?
me too
Hey guys! Is there any news on this?
I am trying out graphql (here: with graphene-django) and I also have this problem -- more specific: the filtering seems not to be working with Enums/Choices..
Thanks!
i am facing the same issue as well
I am also facing the same issue