graphql-python / graphene

GraphQL framework for Python
http://graphene-python.org/
MIT License
8.09k stars 824 forks source link

override resolver MongoengineConnectionField with graphene_mongo #1049

Closed torxx666 closed 5 years ago

torxx666 commented 5 years ago

Hi All I'm using flask + mongo+ graphql, by default I'm can access to classrooms(id="VmVoaWNsZTo1ZDRmZTE5MzZiYmQ1NTJiNmUwYWVlNTU=")

But when I create my resolve_classrooms for classrooms = MongoengineConnectionField(classroom, f_score=graphene.List(graphene.String,required=False), f_color=graphene.List(graphene.String,required=False), f_nbstudent=graphene.List(graphene.String,required=False)....

def resolve_classrooms(self,info,**kwargs):

    query = ClassroomModel.objects()
     if 'f_color' in kwargs:
         f_color  = kwargs['f_color']
         query = query.filter(color__in=f_color)

     if 'f_nbstudent' in kwargs:
         f_nbstudent  = kwargs['f_nbstudent']
         query = query.filter(nbstudent__in=f_nbstudent)

    if 'f_score' in kwargs:
         f_score = kwargs['f_score']
         query = query.filter(score__in=f_score)

    objs = query
    return objs

I can filter by my f_score, f_color.. , I also have access to last ,before, after, when I specify by Id I get them all.

I think that my mistake come from my init (query = ClassroomModel.objects()) but what I need to take as a base ? Is my resolver come after the default ?

thanks to all

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.