Skip to content

Commit

Permalink
Add a query for a single activity given its id
Browse files Browse the repository at this point in the history
  • Loading branch information
supertom01 committed Jun 3, 2024
1 parent 402b5ec commit 2d2d637
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions amelie/activities/graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,18 @@ class Meta:

class ActivitiesQuery(graphene.ObjectType):
activities = DjangoPaginationConnectionField(ActivityType, organizer=graphene.ID())
activity = graphene.Field(ActivityType, id=graphene.ID())

def resolve_activities(self, info, organizer=None, *args, **kwargs):
if organizer:
return Activity.objects.filter(organizer__pk=organizer)
return Activity.objects.all()

def resolve_activity(self, info, id, *args, **kwargs):
if id:
return Activity.objects.get(pk=id)
return None

# Exports
GRAPHQL_QUERIES = [ActivitiesQuery]
GRAPHQL_MUTATIONS = []

0 comments on commit 2d2d637

Please sign in to comment.