升级到AnonymousTraversalSource(Gremlin 3.3.5+ Node.js) [英] Upgrading to AnonymousTraversalSource ( Gremlin 3.3.5+ Node.js)

查看:103
本文介绍了升级到AnonymousTraversalSource(Gremlin 3.3.5+ Node.js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm writing code in Lamda Nodejs12.x

我想更新为未弃用的连接方式

I wanted to update to the not-deprecated way of connecting

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或类似名称.

And then some await g.V().hasLabel or similar.

但是我得到的是: 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

It worked fine the old way with 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);

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

What am I doing wrong? What have I missed?

更新

显然我需要添加travelsource吗?

Apparently I need to add travelsource?

{ traversalSource: 'g' }

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

I cannot find any documentation that added this and it is referenced only sparsly..

更新2

对于懒惰的人:这是我正在工作的代码

For the lazy: Here is the code that I got working

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' }));

推荐答案

我遇到了同样的错误:

TypeError: Cannot read property 'processor' of undefined

traversalSource不是必需的,具体的解决方案是将一个空对象传递给DriverRemoteConnection的第二个参数:

traversalSource is not required, the specific solution is to pass an empty object to the second parameter of DriverRemoteConnection:

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

因此问题似乎是gremlin客户端中缺少的内部null检查.

So the problem seems to be an internal null check that is missing in the gremlin client.

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

When I updated the gremlin server this started to happen, I didn't change anything on the client, strange...

这篇关于升级到AnonymousTraversalSource(Gremlin 3.3.5+ Node.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆