gremlin - Issue with .project().by() in Gremlin JS 3.4.0
问题描述
I'm seeing .project().by()
traversals returning {}
under Gremlin JS 3.4.0
. When I downgrade to 3.2.10
they work correctly.
gremlin> g.addV("trip").property(single, "trackName", "Ohio")
==>v[1]
In Gremlin JS `3.4.0`:
const result = await g.V("1").project("trackName").by("trackName").next();
result:
{
"value": {},
"done": false
}
but when I downgrade to Gremlin 3.2.10
the result is correct:
{
"value": {
"trackName": "Ohio"
},
"done": false
}
Do I need to change how I use project
in 3.4.0
?
EDIT: Results from testing against different versions. I ran each test for a gremlin version, captured results, then bumped up the version and ran the tests again. I am only running a single Neptune instance so we can be sure this is the same data.
A failing test means it returned data in the form of:
"results": {
"value": {},
"done": false
}
For the console testing I removed the final .next()
.
The environment I am testing in is:
AWS Lambda Node 8.10
AWS Neptune 1.0.1.0
EDIT 2: Adding JS files used during Neptune test.
index.js
const gremlin = require("gremlin");
const { DriverRemoteConnection } = gremlin.driver;
const { Graph } = gremlin.structure;
const initGremlinClient = () => {
try {
const dc = new DriverRemoteConnection(
`ws://my-cluster.XXXXXXX.us-east-1.neptune.amazonaws.com:8182/gremlin`,
{}
);
const graph = new Graph();
return {
g: graph.traversal().withRemote(dc),
closeGremlinConnection: () => dc.close()
};
} catch (error) {
console.log("[GREMLIN INIT ERROR]", error);
throw new Error(error);
}
};
exports.handler = async event => {
const { g, closeGremlinConnection } = initGremlinClient();
const result = await g
.addV("test")
.property("myProp", "myValue")
.project("myProp")
.by("myProp")
.next();
closeGremlinConnection();
return result;
};
package.json
{
"name": "gremlinTest",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"gremlin": "3.4.0"
}
}
解决方案
我与 AWS 团队的某个人交谈过。存在影响 Gremlin^3.3.5
和 Lambda 之间互操作性的错误。具体来说,问题在于底层 GraphSON v3 引擎以及 Lambda 如何解析 JSON。
临时解决方法是在实例化时回退到 GraphSON v2 DriverRemoteConnection
:
const dc = new DriverRemoteConnection(
`ws://my-neptune-cluster.us-east-1.neptune.amazonaws.com:8182/gremlin`,
{ mimeType: "application/vnd.gremlin-v2.0+json" } // Fall back to GraphSON v2
);
编辑:这个问题仍然存在gremlin@3.4.6
。
推荐阅读
- mongodb - MongoDB - 如何通过字符串操作更新值
- python - 如何制作一个绘图对象的副本?
- javascript - 在执行过程中动态自动缩放 Phaser 3 游戏
- powershell - Azure 管道 powershell 任务中的 Ant 命令
- c# - 为什么会失败?
- reactjs - React Boilerplate 无法修复点击事件
- wso2 - 如何在选择查询中将输入参数作为输出映射传递
- javascript - 在节点js中签名数据并在Java中验证
- vb.net - Word 互操作 (COM) 样式 LanguageID 不起作用
- c# - 从 PHP 执行存储过程导致“找不到存储过程”