How can you query distinct values with Graphql?

Viewed 848

I'm using django as back-end with a mongoDB and i'm trying to get distinct values with Graphql but i keep getting this error :

"message": "Received incompatible instance \"{'subreddit': 'politics', 'score': 75799}\"."

Here is my schema.py :

class TopicType(DjangoObjectType):
class Meta:
    model = Topic

class Query(graphene.ObjectType):
    all_topics = graphene.List(TopicType)
    topic = graphene.Field(lambda: 
    graphene.List(TopicType),subreddit=graphene.String(),score=graphene.String())
    def resolve_all_topics(self, info,**kwargs):
        return Topic.objects.all()

    def resolve_topic(self,info,**kwargs):
       return Topic.objects.values("subreddit").order_by().annotate(score =Sum("score"))
schema = graphene.Schema(query=Query)

And here is my query

query getTopics{
  topic {
    subreddit

  }}
0 Answers
Related