Check existence graph projection

Hello,

I would like to check if a graph projection exists and if yes, drop it.

Here is the code tried without success:
</>CALL gds.graph.list()
YIELD graphName
WITH graphName AS graph
CALL gds.graph.drop(graph)
YIELD graphName
RETURN graphName</>

Neo4j Kernel:4.4.2:enterprise
gdsVersion:1.8.2
neo4jVersion:4.4.2

Thank you for your help.

Julie

Hello @julie.cavarroc and welcome to the Neo4j community :slight_smile:

You could use directly (doc):

CALL gds.graph.drop('your-graph-name', false) YIELD graphName;

If you want to drop all graph projections:

CALL gds.graph.list()
YIELD graphName
WITH graphName AS g
CALL gds.graph.drop(g, false)
YIELD graphName
RETURN graphName

Regards,
Cobra

Thank you for your answer.

It is for an automatic use. So I need:

  1. Check if the graph projection exists,
  2. If it exists, get the name and drop it by the command you suggest

Regards,
Julie

The query I sent you do the both at the time. It will delete the graph if it exists.

Hello @julie.cavarroc, did you need more help?