Why is this relationship MERGE failing?

I have a short query that contains both a delete as well as a new relationship merge. When I separate them into individual queries, they run as expected. But when I combine them into the same query, the (exp)-[:EDITED_FROM]->(ee) relationship is never created. I've tried all variations of merge before delete, merge after delete, -- as well as fewer or more WITH DISTINCT statements. Any idea why ?

MATCH (ee:EditedExperience{uuid:"f34f7e"})
MATCH (exp:Experience {uuid:"ae67d"})
MATCH (ee)-[r]-() WHERE type(r) <> "EDITED_FROM"
WITH DISTINCT ee,exp,r
MERGE (exp)-[:EDITED_FROM]->(ee)
WITH DISTINCT ee,exp,r
DELETE r
RETURN DISTINCT ee.uuid, exp.uuid

I don't see anything obvious that is wrong.

I created some test data with the following query. The graph is shown below.

create (ee:EditedExperience{uuid:"f34f7e"})
create (exp:Experience {uuid:"ae67d"})
create (ee)-[:X]->(),  (ee)-[:Y]->()

I ran your query and got the following result, which looks like what you want.

Maybe it's something particular to your data. Maybe I could figure it out if I had the data.

In the meantime, I refactored the query. Try this instead. It gave me the same result.

MATCH (ee:EditedExperience{uuid:"f34f7e"})
MATCH (exp:Experience {uuid:"ae67d"})
MERGE (exp)-[:EDITED_FROM]->(ee)
WITH ee, exp
call {
    with ee
    MATCH (ee)-[r]-() WHERE type(r) <> "EDITED_FROM"
    DELETE r
}
RETURN DISTINCT ee.uuid, exp.uuid

Question: Why do you need a DISTINCT? Do you have multiple nodes with the same uuid?

Gary, Thank you for the response!
I tried to make sure I wasn't missing something before submitting my question but, alas, I failed.
I'm working in Desktop and checking my output in Bloom -- and the reason my new relationship wasn't showing is that I hadn't refreshed my perspective... so this new relationship type did not show in the resulting graph!!

Thanks for the work, much appreciated -- including the cool refactor.

Mark

Well, I am glad you verified we both are not mad.