diff --git a/app/api/nodes/route.ts b/app/api/nodes/route.ts index c923174..ec92f63 100644 --- a/app/api/nodes/route.ts +++ b/app/api/nodes/route.ts @@ -257,14 +257,17 @@ export async function POST(request: NextRequest) { // Handle linking if (links && links.length > 0) { - // Find the corresponding cache nodes for the AT-URIs + // Links array contains node IDs (e.g., "node:xxxxx") from the UI + // Verify they belong to this user before creating relations const targetNodesResult = await db.query<[Array<{ id: string }>]>( - 'SELECT id FROM node WHERE user_did = $did AND atp_uri IN $links', + 'SELECT id FROM node WHERE user_did = $did AND id IN $links', { did: userDid, links: links } ); const targetNodes = targetNodesResult[0] || []; + console.log(`[POST /api/nodes] Creating ${targetNodes.length} link relations`); + // Create graph relations for (const targetNode of targetNodes) { await db.query('RELATE $from->links_to->$to', {