1

I've encountered a bug, and here is the minimal replication of it in nodejs.

g.addV("foo").as("x").addV("bar").as("y").addE("relatesTo").from("x").to("y").next();

This is very surprising to me, because it seems to me to follow examples like those here and here. I can't tell the difference.

But here's the error it's giving me.

await this.g.addV("foo").as("x").addV("bar").as("y").addE("relatesTo").from("x").to("y").next();
                                                                       ^

TypeError: this.g.addV(...).as(...).addV(...).as(...).addE(...).from is not a function

Just in case this error was related to the way the connection was set up (which I doubt), and to make it easier for answerers to replicate, here's the entire file (with a few sensitive values removed).

let { fromNodeProviderChain } = require( '@aws-sdk/credential-providers');
let aws4 = require( 'aws4');
let gremlin = require ('gremlin');

class dbManager {
  constructor() {
    this.initNeptuneConnection();
  }

  initNeptuneConnection = async () => {
    const credGetter = fromNodeProviderChain();
    const creds = await credGetter();
    const url = '< your url here >';
    const { host, pathname } = new URL(url);
    const { headers } = await aws4.sign(
      {
        host,
        path: pathname,
        region: 'some region here',
        service: 'neptune-db',
      },
      creds
    );
    const connection = new gremlin.driver.DriverRemoteConnection(url, { headers });
    await connection.open();
    this.g = new gremlin.structure.Graph().traversal().withRemote(connection);
    this.__ = gremlin.process.statics;
    await this.g.addV("foo").as("x").addV("bar").as("y").addE("relatesTo").from("x").to("y").next();
  };
}
let db = new dbManager();

1 Answer 1

2

from() needs to be from_(): https://tinkerpop.apache.org/docs/current/reference/#gremlin-javascript-differences

Otherwise, there are some collisions in reserved syntax in JS vs Gremlin.

2
  • You know, I was worried it might be something like that, in fact, I had even read stackoverflow.com/questions/69049934/…, which prompted me to look up a list of reserved words, and 'from' wasn't on it, so I stopped looking down that path. Perhaps the list I found was just incomplete. Commented Jun 5 at 15:30
  • 1
    Perhaps. The link above is to the official TinkerPop docs. That should be a complete list. Commented Jun 5 at 19:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.