Search code examples
cyphermemgraphdbopencyphercypherl

How to make CYPHERL file more human readable?


I'm currently testing Memgraph(2.11.0) in docker. I have successfully imported my CYPHERL file via Memgraph Lab. However, it's very hard to read and maintain. Is it possible to improve that? Is there a document on the format any where?

Here's example of the CYPHERL file I have except that the WHERE clause in the real thing is longer.

CREATE (:EndPoint {service: "x-svc", owner: "x", method: "POST", path: "accounts/"});
CREATE (:EndPoint {service: "y-svc", owner: "y", method: "GET", path: "wallets/"});
CREATE (:EndPoint {service: "z-svc", owner: "z", method: "GET", path: "files/"});
CREATE (:DataSource {type: "mysql", name: "acc-db"});
MATCH (e:EndPoint), (e2:EndPoint) WHERE e.service = "x-svc" AND e.path = "accounts/" AND e2.service = "y-svc" AND e2.path = "wallets/" CREATE (e)-[:IS_CALLING]->(e2); 
MATCH (e:EndPoint), (d:DataSource) WHERE e.service = "x-svc" AND e.path = "accounts/" AND d.name = "acc-db" CREATE (e)-[:READ_FROM]->(d);
MATCH (e:EndPoint), (e2:EndPoint) WHERE e.service = "y-svc" AND e.path = "wallets/" AND e2.service = "z-svc" AND e2.path = "files/" CREATE (e)-[:IS_CALLING]->(e2); 

Solution

  • The .cypherl format is specific to Memgraph and is designed to house a series of Cypher queries to be executed sequentially. When you export data into a .cypherl file, Memgraph generates a series of Cypher queries, which, when run in the specified order, recreate the database's state. Memgraph utilizes the newline character to delineate the start of a new query; this means that you can't use new lines to break down single queries into multiple lines within a .cypherl file.

    So you are not doing anything wrong. This just isn't supported at this time. You can open up an issues/feature request in Memgraph GitHub repository so that our developers can take this into consideration for future versions.

    Discalimere: I work at Memgraph.