diff --git a/orm/shout.py b/orm/shout.py index 968b7dbb..cba6bddb 100644 --- a/orm/shout.py +++ b/orm/shout.py @@ -68,6 +68,7 @@ class Shout(Base): body = Column(String, nullable=False, comment="Body") slug = Column(String, unique=True) cover = Column(String, nullable=True, comment="Cover image url") + cover_caption = Column(String, nullable=True, comment="Cover image alt caption") lead = Column(String, nullable=True) description = Column(String, nullable=True) title = Column(String, nullable=True) diff --git a/resolvers/author.py b/resolvers/author.py index 1bd255db..f6f308a1 100644 --- a/resolvers/author.py +++ b/resolvers/author.py @@ -173,7 +173,10 @@ async def get_author(_, _info, slug="", user=None, author_id=None): q = add_author_stat_columns(q) authors = get_authors_from_query(q) - return authors[0] + if authors: + return authors.pop() + else: + return {"error": "cant find author"} @query.field("load_authors_by") @@ -201,15 +204,19 @@ async def load_authors_by(_, _info, by, limit, offset): @query.field("get_author_followed") async def get_author_followed(_, _info, slug="", user=None, author_id=None) -> List[Author]: - # First, we need to get the author_id for the given slug - with local_session() as session: + author_id_query = None + if slug: author_id_query = select(Author.id).where(Author.slug == slug) - author_id = session.execute(author_id_query).scalar() + elif user: + author_id_query = select(Author.id).where(Author.user == user) + if not author_id: + with local_session() as session: + author_id = session.execute(author_id_query).scalar() if author_id is None: raise ValueError("Author not found") - - return await followed_authors(author_id) + else: + return await followed_authors(author_id) # Author[] @query.field("get_author_followers") diff --git a/schemas/core.graphql b/schemas/core.graphql index 2f7a4ef4..98d5775d 100644 --- a/schemas/core.graphql +++ b/schemas/core.graphql @@ -126,6 +126,7 @@ type Shout { lang: String community: String cover: String + cover_caption: String layout: String version_of: String visibility: ShoutVisibility