Migrate callers from attach-child/detach-child to relate/unrelate API

Switch all cross-service relation calls to the new registry-aware
relate/unrelate/can-relate actions, and consolidate per-service
container-nav fragment fetches into the generic relations handler.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 09:24:52 +00:00
parent 53c4a0a1e0
commit d2f1da4944
9 changed files with 65 additions and 70 deletions

View File

@@ -93,9 +93,11 @@ class SqlMarketService:
existing.deleted_at = None # revive
existing.name = name
await session.flush()
await call_action("relations", "attach-child", payload={
"parent_type": container_type, "parent_id": container_id,
"child_type": "market", "child_id": existing.id,
await call_action("relations", "relate", payload={
"relation_type": f"{container_type}->market",
"from_id": container_id, "to_id": existing.id,
"label": existing.name,
"metadata": {"slug": existing.slug},
})
return _mp_to_dto(existing)
raise ValueError(f'Market with slug "{slug}" already exists for this container.')
@@ -106,9 +108,11 @@ class SqlMarketService:
)
session.add(market)
await session.flush()
await call_action("relations", "attach-child", payload={
"parent_type": container_type, "parent_id": container_id,
"child_type": "market", "child_id": market.id,
await call_action("relations", "relate", payload={
"relation_type": f"{container_type}->market",
"from_id": container_id, "to_id": market.id,
"label": market.name,
"metadata": {"slug": market.slug},
})
return _mp_to_dto(market)
@@ -130,8 +134,8 @@ class SqlMarketService:
market.deleted_at = utcnow()
await session.flush()
await call_action("relations", "detach-child", payload={
"parent_type": container_type, "parent_id": container_id,
"child_type": "market", "child_id": market.id,
await call_action("relations", "unrelate", payload={
"relation_type": f"{container_type}->market",
"from_id": container_id, "to_id": market.id,
})
return True