authors_by_slugs

This commit is contained in:
2021-11-25 05:45:22 +03:00
parent 9ab334de71
commit 05e8d57bdc
3 changed files with 15 additions and 4 deletions

View File

@@ -2,7 +2,7 @@ from resolvers.auth import login, sign_out, is_email_free, register, confirm
from resolvers.inbox import create_message, delete_message, update_message, get_messages
from resolvers.zine import create_shout, get_shout_by_slug, top_month, top_overall, \
recent_shouts, top_authors, top_viewed
from resolvers.profile import get_user_by_slug, get_current_user
from resolvers.profile import get_user_by_slug, get_current_user, authors_by_slugs
from resolvers.topics import topic_subscribe, topic_unsubscribe, topics_by_author, \
topics_by_community, topics_by_slugs
from resolvers.comments import create_comment
@@ -35,5 +35,6 @@ __all__ = [
"create_community",
"delete_community",
"get_community",
"get_communities"
"get_communities",
"authors_by_slugs"
]

View File

@@ -25,6 +25,14 @@ async def get_current_user(_, info):
user = info.context["request"].user
return { "user": user }
@query.field("authorsBySlugs")
@login_required
async def authors_by_slugs(_, info, slugs):
user = info.context["request"].user
with local_session() as session:
users = session.query(User).where(User.slug in slugs)
return { "authors": users }
@query.field("userRoles")
@login_required
async def user_roles(_, info):