diff --git a/resolvers/zine.py b/resolvers/zine.py index f8bceaf9..39d5686d 100644 --- a/resolvers/zine.py +++ b/resolvers/zine.py @@ -490,12 +490,18 @@ async def shouts_commented_by_user(_, info, slug, page, size): return shouts @query.field("shoutsRatedByUser") -async def shouts_rated_by_user(_, info, slug, page, size): +@login_required +async def shouts_rated_by_user(_, info, page, size): + user = info.context["request"].user + with local_session() as session: shouts = session.query(Shout).\ join(ShoutRating).\ - where(ShoutRating.rater == slug).\ + where(ShoutRating.rater == user.slug).\ order_by(desc(ShoutRating.ts)).\ limit(size).\ offset( (page - 1) * size) - return shouts + + return { + "shouts" : shouts + } diff --git a/schema.graphql b/schema.graphql index 12e692b4..2388c4bd 100644 --- a/schema.graphql +++ b/schema.graphql @@ -50,6 +50,11 @@ type ShoutResult { shout: Shout } +type ShoutsResult { + error: String + shouts: [Shout] +} + type CommentResult { error: String comment: Comment @@ -140,8 +145,8 @@ type Query { userSubscribers(slug: String!): [User]! userSubscribedTopics(slug: String!): [String]! + shoutsRatedByUser(page: Int!, size: Int!): ShoutsResult! shoutsCommentedByUser(slug: String!, page: Int!, size: Int!): [Shout]! - shoutsRatedByUser(slug: String!, page: Int!, size: Int!): [Shout]! # shouts getShoutBySlug(slug: String!): Shout!