How to make CYPHERL file more human readable?

95 Views Asked by At

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); 
2

There are 2 best solutions below

0
Graph Dveler On BEST ANSWER

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.

1
cybersam On

It seems the CYPHERL file format is not explicitly documented anywhere (at least Google is not able to find anything).

But looking at the examples on this Memgraph page, it seems a CYPHERL file just contains a number of opencypher statements, where each statement ends with a semicolon. Each statement is executed as a separate query.