From fa4d13ccf4362fe779d7ef75066fd098135b39c5 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Thu, 28 Jul 2022 06:44:56 +0300 Subject: [PATCH] all authors api --- resolvers/profile.py | 4 ++++ schema.graphql | 1 + storages/users.py | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/resolvers/profile.py b/resolvers/profile.py index 9ae38d64..d41af048 100644 --- a/resolvers/profile.py +++ b/resolvers/profile.py @@ -152,3 +152,7 @@ def author_unfollow(user, slug): else: session.delete(flw) session.commit() + +@query.field("authorsAll") +def get_authors_all(_, info): + return UserStorage.get_all_users() diff --git a/schema.graphql b/schema.graphql index 13304ce7..74fa0924 100644 --- a/schema.graphql +++ b/schema.graphql @@ -173,6 +173,7 @@ type Query { userFollowedCommunities(slug: String!): [Community]! userReactedShouts(slug: String!): [Shout]! # test getUserRoles(slug: String!): [Role]! + authorsAll: [User]! # shouts getShoutBySlug(slug: String!): Shout! diff --git a/storages/users.py b/storages/users.py index 8dd83044..b2ff7d69 100644 --- a/storages/users.py +++ b/storages/users.py @@ -22,6 +22,12 @@ class UserStorage: async with self.lock: return self.users.get(id) + @staticmethod + async def get_all_users(): + self = UserStorage + async with self.lock: + return self.users + @staticmethod async def get_user_by_slug(slug): self = UserStorage