Dataflow Diagram

We imagine depending on programmers to maintain a diagram of how our system works and interacts with external services outside of our control. We source SERVICES with DATASTORES and QUEUES. data

Manually maintained diagrams owned and managed by the architecture team updated within weeks before or after actual deployments.

Extracted data format.

[] MAX 1000 {} REL Flow type CASE type store store from <= NODE Service name CASE type rest from <= NODE Service name to => NODE Service name CASE type queue queue read => NODE Service name write <= NODE Service name CASE type site site from => NODE Service name

create (s:EXPLAIN {props}) with s UNWIND {json} AS obj WITH *, CASE WHEN obj.type='store' THEN [1] ELSE [] END AS stores, CASE WHEN obj.type='rest' THEN [1] ELSE [] END AS rests, CASE WHEN obj.type='queue' and is not null THEN [1] ELSE [] END AS reads, CASE WHEN obj.type='queue' and obj.write is not null THEN [1] ELSE [] END AS writes, CASE WHEN obj.type='site' THEN [1] ELSE [] END AS sites FOREACH (_ IN stores | MERGE (d:DB {name:}) MERGE (g:PROGRAM {name: obj.from}) MERGE (g)-[:QUERIES {source:}]->(d) ) FOREACH (_ IN rests | MERGE (f:PROGRAM {name: obj.from}) MERGE (t:PROGRAM {name:}) MERGE (f)-[:CALLS {source:}]->(t) ) FOREACH (_ IN reads | MERGE (q:QUEUE {name: obj.queue}) MERGE (r:PROGRAM {name:}) MERGE (r)-[:READS {source:}]->(q) ) FOREACH (_ IN writes | MERGE (q:QUEUE {name: obj.queue}) MERGE (w:PROGRAM {name: obj.write}) MERGE (w)-[:WRITES {source:}]->(q) ) FOREACH (_ IN sites | MERGE (x:EXTERNAL {name:}) MERGE (f:PROGRAM {name: obj.from}) MERGE (f)-[:CALLS {source:}]->(x) )

I'm stumped as to how to wrap merges in a case statement that understands the variety in my json. grammar

William Lyon suggested this alternative. neo4j