1

Hi I have this snippet of my traversal that's causing some issues.

I'm using gremlin js and aws neptune.

.choose(
        token !== undefined,
        __.choose(
            __.select('v').has(`${engagementType}Token`),
                __.choose(
                    __.select('v').values(`${engagementType}Timestamp`).is(p.lt(token!.timestamp)),
                    __.select('v')
                        .property(c.single, `${engagementType}Timestamp`, token!.timestamp)
                        .property(c.single, `${engagementType}Token`, token!.id),
            ),
            __.select('v')
                .property(`${engagementType}Timestamp`, token!.timestamp)
                .property(`${engagementType}Token`, token!.id),
         ),
)

I'm getting an error indicating that timestamp is being evaluated when it's undefined. According to this traversal though it should only be evaluated when it isn't undefined.

Any idea as to what I'm missing here?

Thanks!

Kyano
  • 174
  • 1
  • 8
  • I'm not 100% sure what might be going on here as `choose(boolean-literal....)` is not a valid signature for the `choose` step. The first parameter should be a traversal that essentially equates to true or false. If you replace `token !== undefined` with a traversal, does the query complete? – Kelvin Lawrence Aug 08 '22 at 23:52
  • I tried evaluating with __.V().has('aldkjflajdf','aldkjalf'), a random string and it's still evaluating the same way. Super weird. Does it mean all variables have to be valid in a gremlin traversal even when they aren't necessarily going to be traversed? – Kyano Aug 09 '22 at 08:45
  • Worth noting that I also tried to wrap the boolean in a constant before this and it didn't work either – Kyano Aug 09 '22 at 10:03
  • Well you would need to do it like this `g.V(1).choose(constant(false).is(true),constant('yes'),constant('no')) ` – Kelvin Lawrence Aug 09 '22 at 13:37
  • I tried that too! – Kyano Aug 09 '22 at 14:03
  • Do you have a Gremlin Console or a graph-notebook available/connected? I would be tempted to get the query working as straight Gremlin (no variables etc.) and then see if that can be back-ported to the JavaScript code. Something is not quite adding up in the way you are seeing the JS client behave. – Kelvin Lawrence Aug 09 '22 at 22:10
  • I don't have a notebook or console. I can send you the traversal itself but its about 70 lines haha. lmk if you still want to review it – Kyano Aug 12 '22 at 09:23

0 Answers0