Motif可视化工具导入Neo4j数据时遇Neo4jError报错求助
问题:Motif.gl连接Neo4j默认电影数据库后页面空白并报错
环境与操作步骤
- 克隆完整的Motif数据可视化项目(仓库地址:https://github.com/cylynx/motif.gl)
- 安装Neo4j Desktop并启用默认电影数据库,该数据库已通过
bolt://localhost在Neo4j浏览器中正常运行 - 进入
/motif.gl/packages目录,执行npm run build和npm run serve启动项目(启动脚本位于/motif.gl/packages/motif-demo/package.json) - 访问
localhost:3000,在Neo4j数据导入页面填写主机、端口、账号密码完成连接,点击「继续」后页面空白,控制台抛出以下错误:
Uncaught Neo4jError: This record has no field with key 'error', available key are: [name,type,aliases,access,address,role,writer,requestedStatus,currentStatus,statusMessage,default,home,constituents].
已尝试的解决方案
修改了motif-demo/src/containers/Neo4J/sections/ExecuteQuery/ExecuteQuery.tsx中的onQueryData方法,重新构建Vite打包器后问题依旧。修改后的方法代码如下:
const onQueryData = (e: React.FormEvent) => { e.preventDefault(); if (db.length === 0) { return; } setIsLoading(true); (driver as Driver) .session({ database: db[0].id as string }) .run(query) .then(async (res: QueryResult) => { const records = res.records; const hasError = records.some(record => 'error' in record); if (hasError) { // Handle errors if necessary throw new Error('Neo4jError: Query execution returned an error.'); } const { nodes, edges } = await toMotifFormat(records as Record[]); return { nodes, edges }; }) .then((data: GraphData) => { const { nodes, edges } = data; onStateChange('graphData', data); const nodeLength = nodes.length; const edgesLength = edges.length; setNotification({ kind: 'positive', children: ( <Block as='span'> Imported <b>{nodeLength} Node(s)</b> and{' '} <b>{edgesLength} Edge(s)</b>. </Block> ), }); }) .catch((error) => { onStateChange('graphData', { nodes: [], edges: [], }); setNotification({ kind: 'negative', children: error.message, }); }) .finally(() => { setIsLoading(false); }); };
期望效果
页面能正常显示包含节点和边的电影数据库图谱可视化内容。
内容的提问来源于stack exchange,提问作者Brian Blocher
相关产品推荐
相关产品推荐

