I am attempting to use two lists to create nodes/relationships in cypher. Using the solution for this related question, my current solution is:
MERGE (t:Test)
WITH t
UNWIND ["a","b"] AS name // first list
MERGE (t)-[:FOO_REL]->(a:Foo { name: name })
WITH DISTINCT t
UNWIND [100,200] AS id // second list
MERGE (t)-[:BAR_REL]->(b:Bar { id: id })
This works as long as both lists have entries in them. However, if the first list is empty then the second list is never unwound (and no :Bar nodes are created).
How would I go about chaining UNWINDs such that I can create nodes/relationships from two separate lists in a single query?