How to check if graph is empty?

I have a cypher script that is automatically run when a docker container starts. I'd like to run n10s.graphconfig.init() when the container was run for the first time. However, after that it gives an error. It's not causing any issue but I'd like to check if the error message could be avoided by running the init() call only if the graph is empty.

The error message says:

n10s.graphconfig.init`: Caused by: n10s.graphconfig.GraphConfigProcedures$GraphConfigException: The graph is non-empty

match (n) return count(n)?

Yep, that would do.
To be more precise, the procedure will refuse to run if there is at least a node labeled as :Resource or in other words, if there is some RDF data imported in the DB. Because if that is the case, some config was applied for that import and changing it without cleaning the DB would mess things up.
Here's where this happens.

@dazhi.jiao Is it expected to start a container with a pre-populated DB?

You can do two things, like @david.rosenblum mentioned you could check if there are any nodes, you can restrict it to (n:Resource) if you prefer. Or you can check if there is already a graph config in the DB. You can get it with n10s.graphconfig.show()

Hope this helps.

JB.