Files
X-Agents/teams/api/neo4j-graph-save.md
2026-03-11 14:26:47 +08:00

1.5 KiB

Neo4j 图谱保存接口需求

需求说明

前端需要保存 Neo4j 图谱的连接信息,以便后续快速加载和查看。


接口地址

POST /database/graph/save

请求参数

参数 类型 必填 说明
databaseId string 数据库 ID
databaseName string 数据库名称
uri string Neo4j 连接地址,如 bolt://localhost:7687
username string 用户名
labels array 标签列表
relationshipTypes array 关系类型列表
selectedLabel string 当前选中的标签

请求示例

{
  "databaseId": "123",
  "databaseName": "neo4j",
  "uri": "bolt://10.10.10.189:7687",
  "username": "neo4j",
  "labels": ["User", "Order", "Product"],
  "relationshipTypes": ["KNOWS", "BOUGHT", "BELONGS_TO"],
  "selectedLabel": "User"
}

返回参数

参数 类型 说明
success bool 是否成功
message string 消息

返回示例

{
  "success": true,
  "message": "保存成功"
}

前端调用示例

fetch('/database/graph/save', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    databaseId: '123',
    databaseName: 'neo4j',
    uri: 'bolt://10.10.10.189:7687',
    username: 'neo4j',
    labels: ['User', 'Order', 'Product'],
    relationshipTypes: ['KNOWS', 'BOUGHT', 'BELONGS_TO'],
    selectedLabel: 'User',
  }),
})