diff --git a/resolvers/__init__.py b/resolvers/__init__.py index 96d9588f..585f1261 100644 --- a/resolvers/__init__.py +++ b/resolvers/__init__.py @@ -24,6 +24,7 @@ from resolvers.reaction import ( delete_reaction, load_reactions_by, load_shouts_followed, + load_shouts_followed_by, update_reaction, ) from resolvers.reader import ( @@ -76,6 +77,7 @@ __all__ = [ "load_shouts_feed", "load_shouts_search", "load_shouts_followed", + "load_shouts_followed_by", "load_shouts_unrated", "load_shouts_random_top", "load_shouts_random_topic", diff --git a/resolvers/reaction.py b/resolvers/reaction.py index 7524ee3a..747de0e1 100644 --- a/resolvers/reaction.py +++ b/resolvers/reaction.py @@ -496,3 +496,17 @@ async def load_shouts_followed(_, info, limit=50, offset=0) -> List[Shout]: except Exception as error: logger.debug(error) return [] + + +@query.field("load_shouts_followed_by") +async def load_shouts_followed_by(_, info, slug: str, limit=50, offset=0) -> List[Shout]: + with local_session() as session: + author = session.query(Author).filter(Author.slug == slug).first() + if author: + try: + author_id: int = author.dict()["id"] + shouts = await reacted_shouts_updates(author_id, limit, offset) + return shouts + except Exception as error: + logger.debug(error) + return [] diff --git a/schema/query.graphql b/schema/query.graphql index 926e6265..c57f4c41 100644 --- a/schema/query.graphql +++ b/schema/query.graphql @@ -18,7 +18,8 @@ type Query { get_author_follows(slug: String, user: String, author_id: Int): CommonResult! get_author_follows_topics(slug: String, user: String, author_id: Int): [Topic] get_author_follows_authors(slug: String, user: String, author_id: Int): [Author] - load_shouts_followed(limit: Int, offset: Int): [Shout] # userReactedShouts + load_shouts_followed(limit: Int, offset: Int): [Shout] + load_shouts_followed_by(slug: String, limit: Int, offset: Int): [Shout] # reaction load_reactions_by(by: ReactionBy!, limit: Int, offset: Int): [Reaction]