def soft_delete_aware_query(context, *args, **kwargs):
    """Stack query helper that accounts for context's `show_deleted` field.

    :param show_deleted: if True, overrides context's show_deleted field.
    """
    query = context.session.query(*args)
    show_deleted = kwargs.get('show_deleted') or context.show_deleted
    if not show_deleted:
        query = query.filter_by(deleted_at=None)
    return query
