I have a Gremlin query where I need to check almost in every step if the passed param values are found, if yes then proceed to the next step otherwise exit the query with an error message which will be different in each step.
My sample data can be found here https://gremlify.com/wczryzotbf/1
An employee id, manager name, and designation(s) can be passed as params. My query is not taking designation param yet which I am yet to write.
The following query does not return any error message if an invalid employee id like 100 is passed. If I pass a valid employee id like 1 in this case it works as expected.
However I pass the correct employee id but the incorrect manager name, an error message Manager not found is returned as expected.
g.V().
has('emp', 'emp_id', 100).as('empview').
choose(
select('empview').count(local).is(eq(0)),
constant("Employee Id not found"),
choose(
outE().
hasLabel('emp-mgr').
has('start_date', gte(1643702400)).
inV().
has('manager', 'manager_name', 'manager2'),
__.outE().
hasLabel('emp-mgr').as('edgeview').
has('start_date', gte(1643702400)).
inV().
has('manager', 'manager_name', 'manager2').as('managerview').
select('empview', 'edgeview', 'managerview').
by(
valueMap(
'emp_id',
'emp_name',
'start_date',
'end_date',
'manager_name')),
constant("Manager not found")))
Now if I change the query to write has clause in the 2nd line within choose step it shows the error message for an invalid id but the query is executed for each employee vertex.
g.V()
choose(not(has('emp','emp_id', 1)),
constant("Employee Id not found"),......
How I can show an error message if an employee id is not found?
Also once I traverse from an employee vertex to a manager vertex I need to collect data from the manager vertex and then I need to go back to the employee vertex to traverse the employee to the designation vertex using "emp-desig" edge and do the same validation step there. How i can go back to a node and traverse different path from there?
I am using the AWS Neptune database. My actual query will be written in gremlin python.