Fabric error - "Dynamic graph lookup not allowed here. This feature is only available in a Fabric database"

Using this tutorial as inspiration I have the following fabric config (real db names & IPs changed):

- NEO4J_fabric_database_name=fabric
# db1 (local)
- NEO4J_fabric_graph_0_uri=neo4j://localhost:7687
- NEO4J_fabric_graph_0_name=db1
- NEO4J_fabric_graph_0_database=domain1
# db2 (local)
- NEO4J_fabric_graph_1_uri=neo4j://localhost:7687
- NEO4J_fabric_graph_1_name=db2
- NEO4J_fabric_graph_1_database=domain2
# db3 (remote)
- NEO4J_fabric_graph_2_uri=neo4j://123.456.789:7687
- NEO4J_fabric_graph_2_name=db3
- NEO4J_fabric_graph_2_database=domain3

When the server has started, I'm able to confirm 3 dbs in the fabric catalog:

RETURN fabric.graphIds()

And any of the three dbs can be individually accessed, e.g:

USE fabric.db1
MATCH (p:Post)
RETURN count(p)

But if I try and cycle through all dbs in the catalog in a single query, as shown in the tutorial, this error is generated:

UNWIND fabric.graphIds() as graphId
    USE fabric.graph(graphId)
    MATCH (p:Post)
    RETURN count(p) as postCount
RETURN postCount
Dynamic graph lookup not allowed here. This feature is only available in a Fabric database
Attempted to access graph fabric.graph(graphId)
"USE fabric.graph(graphId)"

Running Neo4j Enterprise 4.1.

My guess (as an Intermediate-level neo4j user) is you're misusing the USE statement.

graphId is actually a list of IDs (created by UNWIND), which I don't think USE will be happy with.

I think you need to use the FOREACH to loop on each GraphId so that the USE will get just one at a time,

But that's my guess.... I could be wrong... I hope that helps.

Hi @terryfranklin82 and anyone else who experiences the same issue,

I had the same problem when running similar queries from my Jupyter notebook against a docker hosted Neo4j instance hosting my virtual fabric database. The issue was, when I connected to Neo4j, the default database is set to 'neo4j' and not the virtual fabric database. What I did to resolve the issue was adding NEO4J_dbms_default__database: <fabric-name> to the environment variable of the fabric container. Restarted all my containers and dynamic graph lookup was finally allowed!

Kind regards,