2

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.

enter image description here

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"
  }
}
4

1 回答 1

3

我与 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

于 2019-03-22T15:16:01.390 回答