From de63f313a5f8409770b5d8a70eb1317e648bdaf9 Mon Sep 17 00:00:00 2001 From: Untone Date: Sat, 9 Dec 2023 22:02:04 +0300 Subject: [PATCH] paginated-authors --- resolvers/__init__.py | 4 ++-- resolvers/author.py | 5 +++-- schemas/core.graphql | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/resolvers/__init__.py b/resolvers/__init__.py index df347e16..30c469b9 100644 --- a/resolvers/__init__.py +++ b/resolvers/__init__.py @@ -2,7 +2,7 @@ from resolvers.editor import create_shout, delete_shout, update_shout from resolvers.author import ( get_author, - get_authors_all, + load_authors_all, get_author_followers, get_author_followed, load_authors_by, @@ -31,7 +31,7 @@ from resolvers.community import get_community, get_communities_all __all__ = [ # author "get_author", - "get_authors_all", + "load_authors_all", "get_author_followers", "get_author_followed", "load_authors_by", diff --git a/resolvers/author.py b/resolvers/author.py index f6f308a1..ac0728a7 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -151,11 +151,12 @@ def author_unfollow(follower_id, slug): return False -@query.field("get_authors_all") -async def get_authors_all(_, _info): +@query.field("load_authors_all") +async def load_authors_all(_, _info, limit: int = 50, offset: int = 0): q = select(Author) q = add_author_stat_columns(q) q = q.join(ShoutAuthor, Author.id == ShoutAuthor.author) + q = q.limit(limit).offset(offset) return get_authors_from_query(q) diff --git a/schemas/core.graphql b/schemas/core.graphql index e3544b46..e1f7db96 100644 --- a/schemas/core.graphql +++ b/schemas/core.graphql @@ -331,7 +331,7 @@ type Mutation { type Query { # author get_author(slug: String, user: String, author_id: Int): Author - get_authors_all: [Author] + load_authors_all(limit: Int, offset: Int): [Author] get_author_followers(slug: String, user: String, author_id: Int): [Author] get_author_followed(slug: String, user: String, author_id: Int): [Author] load_authors_by(by: AuthorsBy, limit: Int, offset: Int): [Author]