I'm new to Gremlin, and I was pulling my hair out trying to get things to work via Javascript, when I finally decided to dig into the Javascript files installed for Gremlin by npm. Based on my reading of the code, it seems that most of my problems stemmed from inaccuracies and omissions in the official Gremlin reference documentation.
Most of these suggested imports are listed as "gremlin.process.traversal..." when they should actually just be "gremlin.process...". For example, this doesn't work:
const pop = gremlin.process.traversal.pop
but this does:
const pop = gremlin.process.pop
I tried changing all of these in my own imports, and it seems to work fine.
As for omissions, this documentation fails to include any mention that I could find of how you need to reference these objects in writing your Gremlin code in Javascript. So, for example, it was only through reading through the Gremlin Javascript files that I was able to figure out that the Gremlin query "select(all, 'a')" needed to be written in Javascript as "select(pop.all, 'a')".
I'll also note that the listing of "Common Imports" didn't list all of the imports I needed for my own Gremlin queries. Specifically, there was no import for "withOptions", so I just added the line "const withOptions = gremlin.process.withOptions".
I'm not a full-time coder/engineer, so it's certainly possible I've got some of this wrong. Thus, I was hesitant to try to propose any changes in the documentation directly via a pull request, but let me know if you think I should.
(Oh, as a side note, I'm using Gremlin on Amazon Neptune, but I don't believe that changes any of the basic facts here.)