def swap(httpreq: Request, relationship_id: str) -> graph.Relationship:
    """Swaps the source and target of a relationship."""
    relationship = graph.Relationship.get(relationship_id)
    if relationship is None:
        raise HTTPException(
            status_code=404, detail=f"Relationship {relationship_id} not found"
        )
    relationship.swap_link()
    return relationship
Swaps the source and target of a relationship.
core/web/apiv2/graph.py