How to re-use a query fragment?

I want to find a way to re-use a fragment of a Cypher query without doing copy and paste.

Here is a vanilla example query

MATCH path=(ca:City {name:'CityA'})-[*1..3]-(cd:City {name:'CityD'})
WHERE ANY(n IN nodes(path)[1..-1] WHERE n:City AND EXISTS((n)-[:Path]->(:Lake)))
RETURN path

Let's say sometimes I want to do this instead:

MATCH path=(ca:City {name:'CityA'})-[*1..3]-(cd:City {name:'CityD'})
WHERE ANY(n IN nodes(path)[1..-1] WHERE n:City AND EXISTS((n)-[:Path]->(:Lake)))
RETURN nodes(path)

So instead of copy-n-pasting the first two lines, I hope there is a way to re-use them, resulting in something like:

run_common_query_fragment
RETURN relationships(path)

Is there such a thing in neo4j?

No there isnโ€™t. You could deploy something as a custom procedure, but I donโ€™t see the point for your scenario. APOC has custom procedures where you can define a cypher query as a custom procedure and the call it in your cypher using CALL.