【问题标题】:Upgrading to AnonymousTraversalSource ( Gremlin 3.3.5+ Node.js)升级到 AnonymousTraversalSource (Gremlin 3.3.5+ Node.js)
【发布时间】:2020-10-18 18:58:06
【问题描述】:

我正在用 Lamda Nodejs12.x 编写代码

我想更新到不被弃用的连接方式

const gremlin = require('gremlin');
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;
const traversal = gremlin.process.AnonymousTraversalSource.traversal;

const clusterEndpoint = process.env.CLUSTER_ENDPOINT;
const port = process.env.CLUSTER_PORT;

const connectionStrArray = [];
connectionStrArray.push("wss://");
connectionStrArray.push(clusterEndpoint);
connectionStrArray.push(":");
connectionStrArray.push(port.toString());
connectionStrArray.push("/gremlin");

let joinedConnection = connectionStrArray.join("")
console.log(joinedConnection)
let dc = new DriverRemoteConnection(joinedConnection);

const g = traversal().withRemote(dc)

然后是一些await g.V().hasLabel 或类似的。

但我得到的只是: Cannot read property 'processor' of undefined

使用 Graph (3.3.4) 的旧方式运行良好 https://github.com/apache/tinkerpop/blob/3.3.5/CHANGELOG.asciidoc#release-3-3-5

const graph = new Graph();
const g = graph.traversal().withRemote(dc);

我做错了什么? 我错过了什么?

更新

显然我需要添加 travelsource?

{ traversalSource: 'g' }

我找不到任何添加此内容的文档,并且仅被少量引用..

更新 2

对于懒人:这是我开始工作的代码

const gremlin = require('gremlin');
const traversal = gremlin.process.AnonymousTraversalSource.traversal;
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection;

const clusterEndpoint = process.env.CLUSTER_ENDPOINT;
const port = process.env.CLUSTER_PORT;

const connectionStrArray = [];
connectionStrArray.push("wss://");
connectionStrArray.push(clusterEndpoint);
connectionStrArray.push(":");
connectionStrArray.push(port.toString());
connectionStrArray.push("/gremlin");

const g = traversal().withRemote(new DriverRemoteConnection(connectionStrArray.join(""), { traversalSource: 'g' }));

【问题讨论】:

    标签: node.js lambda gremlin


    【解决方案1】:

    同样的错误发生在我身上:

    TypeError: Cannot read property 'processor' of undefined
    

    traversalSource 不是必须的,具体解决方法是给DriverRemoteConnection的第二个参数传入一个空对象:

    const g = traversal().withRemote(new DriverRemoteConnection(process.env.DATABASE_URL_LOCAL, {}));
    

    所以问题似乎是 gremlin 客户端中缺少内部空检查。

    当我更新 gremlin 服务器时,这种情况开始发生,我没有在客户端上进行任何更改,奇怪...

    【讨论】:

    • 您认为有办法与开发人员核实吗?他们似乎有一个 Jira,但仅限于“真正的错误报告”。现在我只想知道它是否是一个错误:D
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-21
    • 2020-09-29
    相关资源
    最近更新 更多