diff --git a/resolvers/comments.py b/resolvers/comments.py index 0c23fe0f..9663590e 100644 --- a/resolvers/comments.py +++ b/resolvers/comments.py @@ -2,7 +2,7 @@ from orm import Comment, CommentRating from orm.base import local_session from orm.shout import ShoutCommentsSubscription from orm.user import User -from resolvers.base import mutation +from resolvers.base import mutation, query from auth.authenticate import login_required from datetime import datetime @@ -130,6 +130,7 @@ def get_subscribed_shout_comments(slug): slugs = [row.shout for row in rows] return slugs -def get_top10_comments(): +@query.field("commentsAll") +def get_top10_comments(_, info, page = 1, size = 10): with local_session() as session: - rows = session.query(Comment).limit(10).all() + rows = session.query(Comment).limit(size).all() diff --git a/schema.graphql b/schema.graphql index c42e6e88..13f842e0 100644 --- a/schema.graphql +++ b/schema.graphql @@ -200,19 +200,27 @@ type Query { inviteAuthor(slug: String!, author: String!): Result! removeAuthor(slug: String!, author: String!): Result! - # mainpage + # mainpage articles' feeds topViewed(page: Int!, size: Int!): [Shout]! topMonth(page: Int!, size: Int!): [Shout]! topOverall(page: Int!, size: Int!): [Shout]! recentPublished(page: Int!, size: Int!): [Shout]! - # feed + # all articles' feed recentAll(page: Int!, size: Int!): [Shout]! + commentsAll(page: Int!, size: Int!): [Comment]! + # NOTE: so-named 'collections' are tuned feeds + # TODO: createFeed updateFeed deleteFeed mergeFeeds # topics topicsAll(page: Int!, size: Int!): [Topic]! topicsByCommunity(community: String!): [Topic]! topicsByAuthor(author: String!): [Topic]! + # TODO: CMUD for topic + # createTopic(input: TopicInput!): TopicResult! + # mergeTopics(t1: String!, t2: String!): Result! + # updateTopic(input: TopicInput!): TopicResult! + # destroyTopic(slug: String!): Result! # communities getCommunity(slug: String): Community!