# /node/graph 接口前端操作指南(元数据图谱查询) ## 基本信息 - **URL**:`/node/graph`(实际完整路径取决于 meta_data 蓝图前缀,例如 `/api/meta_data/node/graph`) - **方法**:`POST` - **请求体**:`application/json` - **返回格式**:`application/json` ## 功能概述 提交一个 `nodeId`,返回: - `node`:该节点的属性信息(即便没有任何关联关系也会返回)。 -.`related_nodes`:与该节点存在关系的其他节点(包含属性)。 - `relationships`:关系列表,含 `source`、`target`、`type`、`id`。 ## 请求参数 | 字段 | 类型 | 必填 | 说明 | | --- | --- | --- | --- | | nodeId | int | 是 | Neo4j 节点 ID,必须为整数 | 错误时返回: - `code=500`,`message` 为错误描述(如 `nodeId 必须为整数`)。 ## 响应结构 成功(`code=200`,`message="success"`)示例: ```json { "code": 200, "message": "success", "data": { "node": { "id": 123, "name_zh": "示例节点", "name_en": "sample_node", "...": "其他属性" }, "related_nodes": [ { "id": 456, "name_zh": "关联节点A", "...": "其他属性" } ], "relationships": [ { "id": 789, "source": 123, "target": 456, "type": "REL_TYPE" } ] } } ``` 当节点存在但无任何关系时: ```json { "code": 200, "message": "success", "data": { "node": { "id": 123, "...": "节点属性" }, "related_nodes": [], "relationships": [] } } ``` ## 调用示例 ```http POST /node/graph Content-Type: application/json { "nodeId": 123 } ``` ## 前端接入提示 - 使用 `POST` 且 `Content-Type: application/json`。 - `nodeId` 必须为整数;非整数后端会返回错误。 - 前端可直接用 `data.node` 展示当前节点属性;`data.related_nodes` 渲染侧边列表或标签;`data.relationships` 可用于绘制边。 - 关系的 `source` 和 `target` 均为 Neo4j 节点 ID,可与 `node` 与 `related_nodes` 对应。 - 若需区分箭头方向或类型,请使用 `type` 字段做样式映射。