authors_by_slugs

This commit is contained in:
Tony Rewin 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.inbox import create_message, delete_message, update_message, get_messages
from resolvers.zine import create_shout, get_shout_by_slug, top_month, top_overall, \ from resolvers.zine import create_shout, get_shout_by_slug, top_month, top_overall, \
recent_shouts, top_authors, top_viewed 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, \ from resolvers.topics import topic_subscribe, topic_unsubscribe, topics_by_author, \
topics_by_community, topics_by_slugs topics_by_community, topics_by_slugs
from resolvers.comments import create_comment from resolvers.comments import create_comment
@ -35,5 +35,6 @@ __all__ = [
"create_community", "create_community",
"delete_community", "delete_community",
"get_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 user = info.context["request"].user
return { "user": 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") @query.field("userRoles")
@login_required @login_required
async def user_roles(_, info): async def user_roles(_, info):

View File

@ -120,8 +120,7 @@ type Query {
getMessages(count: Int = 100, page: Int = 1): [Message!]! getMessages(count: Int = 100, page: Int = 1): [Message!]!
# shouts # shouts
getShoutBySlug(slug: String!): Shout! getShoutBySlug(slug: String!): Shout! # NOTE: with .comments: Comments[]
# NOTE: with .comments: Comments[]
shoutsByTopic(topic: String!, limit: Int!): [Shout]! shoutsByTopic(topic: String!, limit: Int!): [Shout]!
shoutsByAuthor(author: String!, limit: Int!): [Shout]! shoutsByAuthor(author: String!, limit: Int!): [Shout]!
shoutsByCommunity(community: String!, limit: Int!): [Shout]! shoutsByCommunity(community: String!, limit: Int!): [Shout]!
@ -143,6 +142,9 @@ type Query {
# communities # communities
getCommunity(slug: String): Community! getCommunity(slug: String): Community!
getCommunities: [Community]! getCommunities: [Community]!
# my feed
authorsBySlugs(slugs: [String]!): [User]!
} }
############################################ Subscription ############################################ Subscription