Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you use the sideEffect() method in the Gremlin npm package

I've tried various ways of calling sideEffect(), but none have worked, I can't find any documentation or examples online, and the source code is a bit too abstract for me to understand without spending considerably longer looking at it.

As an example:

const y = await g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect('drop()').next();

Results in

Error: Server error: {"requestId":"8915089a-cde3-4861-b73a-2534cefbc0b2","code":"InternalFailureException","detailedMessage":"Could not locate method: NeptuneGraphTraversal.sideEffect([drop()])"} (599)

I'm running these traversals against AWS Neptune in case that matters (although running similar queries through Python and the Gremlin Console against Neptune work).

like image 922
Dan Avatar asked Sep 18 '25 05:09

Dan


1 Answers

The sideEffect() step takes an anonymous traversal so the syntax I provided in your previous question should work equally well in every Gremlin Language Variant including javascript:

g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(drop())

drop() is of course spawned from __ and should be part of your standard imports and can be called more explicitly as:

const __ = gremlin.process.statics;
g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(__.drop())

The error you describe in your question is simply related to your usage where you pass drop() as a string value. That said, I suppose it's possible that neptune doesn't support sideEffect() as a step at all?? You could test it with a more simple traversal with legitimate syntax and see if you get the same error:

g.V().hasId('a4b64522-9cda-1b34-8f76-634242933a0d').sideEffect(__.constant(1))

If that traversal returns a Vertex with the specified id you were querying for and you don't see an error then I would think sideEffect() as being a supported step. Perhaps someone with more Neptune experience will be able to offer a more official answer for you.

like image 133
stephen mallette Avatar answered Sep 21 '25 18:09

stephen mallette