Can you set cypher.lenient_create_relationship = true in Aura

Hi @mike2,

The best thing to do with cypher is to use the case when for each hack :joy: (and a bit of moving around to your original query). Below is how I tested it:

Set up some params in the browser:

:param authorId => 1;
:param event: { foo: 'foo', bar: 'bar',  uid: 1 } ;
:param locationId => 1;
:param startDateId => 1234;
:param endDateId => 2345;

Created a user:

CREATE (u:User {user_id: $authorId})

With nothing in the DB, the first time around we're only going to get the Author relationship between a user and an Event.

OPTIONAL MATCH (l:Location{uid: $locationId})
OPTIONAL MATCH (start:Dates{uid: $startDateId})
OPTIONAL MATCH (end:Dates{uid: $endDateId})
WITH *
MATCH (u:User{user_id: $authorId})
MERGE (e:Event{uid: $event.uid})
ON CREATE SET e = $event
MERGE (e)-[:AUTHOR]->(u)
FOREACH (_ IN CASE WHEN l IS NOT NULL THEN [1] END | MERGE (e)-[:WHERE]->(l))
FOREACH (_ IN CASE WHEN start IS NOT NULL THEN [1] END | MERGE (e)-[:START]->(start))
FOREACH (_ IN CASE WHEN end IS NOT NULL THEN [1] END | MERGE (e)-[:END]->(end))

Now I can load another node in:

CREATE (l:Location {uid: 1, foobar: 'foobar'})

Give it a go and hopefully that solves your problem.

Cheers,
LG