From 94be60304ed9ac4ae4adc01005414f8a4dde390e Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 7 Mar 2024 14:46:03 +0300 Subject: [PATCH] refactored-get-my-shout-topics --- resolvers/editor.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/resolvers/editor.py b/resolvers/editor.py index 15027eae..2cc9a4ab 100644 --- a/resolvers/editor.py +++ b/resolvers/editor.py @@ -22,11 +22,17 @@ from services.logger import root_logger as logger @query.field('get_my_shout') @login_required async def get_my_shout(_, info, shout_id: int): - with local_session() as session: + with (local_session() as session): user_id = info.context.get('user_id', '') if not user_id: return {'error': 'unauthorized', 'shout': None} - shout = session.query(Shout).filter(Shout.id == shout_id).first() + shout = session.query(Shout).filter( + Shout.id == shout_id + ).options( + joinedload(Shout.authors), joinedload(Shout.topics) + ).filter(and_( + Shout.deleted_at.is_(None), + Shout.published_at.is_(None))).first() if not shout: return {'error': 'no shout found', 'shout': None} if not shout.published_at: