Skip to content

Commit

Permalink
add resolver for user
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliusChrona committed Oct 4, 2020
1 parent 9a66013 commit c7b57ec
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/beds/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ def resolve_beds(self, info):
return Bed.objects.all()


def resolve_beds_for_user(self, info, gardenId=None):
user = info.context.user
try:
if user.is_anonymous:
raise Exception("Not logged in, so you don't have ")
except Exception:
raise
else:
filter_params = {}
if gardenId:
filter_params = {'garden': gardenId}
filter_params.update({'garden__owner': user})
return beds.objects.filter(**filter_params)



class Mutation(graphene.ObjectType):
create_bed = CreateBed.Field()

Expand Down

0 comments on commit c7b57ec

Please sign in to comment.