Facing Issues Executing spatial.intersects with Write Permissions in Neo4j-GraphQL

Hello Neo4j Community,

I am working on a Neo4j-GraphQL integration and attempting to use the spatial.intersects function to query spatial data using @cypherschema.

The problem is that spatial.intersects require write permissions and as a result i get this error:

Neo4jError: Writing in read access mode not allowed. Attempted write to internal graph 0 (neo4j

My questions

  1. How can I configure Neo4j-GraphQL to allow queries with WRITE permissions for spatial.intersects?
  2. Is there a way to use spatial.intersects in read-only mode if the dataset does not need to be modified?
  3. Are there specific best practices for managing write-permission queries within a GraphQL API powered by Neo4j?

Any guidance or advice is much appreciated. Thanks in advance

Hello @sgs97

Can you post a snippet from your type definitions please?

Thank you Michael!!!

Here it is the statement and the type definitions that I am using :

type Establecimiento {
    nombre: String!
    punto: Point! 
}

type TipoEstablecimiento {
    tipo: String!
    numero_establecimientos: Int!
    establecimientos: [Establecimiento!]!
}


type Seccion_Censal @node {
    codigo_seccion: String!,
    geometry: String,
    seccion: String,
    tipos_establecimientos: [TipoEstablecimiento!]! @cypher(
        statement: """
            MATCH (s:Seccion_Censal{codigo_seccion:'03008'})
            CALL spatial.intersects('map', s.geometry) YIELD node AS nodo
            MATCH (nodo)<-[:GEOM]-(o:OSMWay)-[:TAGS]-(t:OSMTags)
            MATCH (o)-[:FIRST_NODE]->(:OSMWayNode)-[:NODE]-(n:OSMNode)
            WHERE (t.name IS NOT NULL) AND (t.amenity IS NOT NULL OR t.leisure IS NOT NULL)
            WITH DISTINCT t, t.amenity AS amenity, t.leisure AS leisure, n
            WITH CASE 
                WHEN t.amenity IS NULL THEN t.leisure
                ELSE t.amenity
                END AS tipo, COLLECT({nombre: t.name, punto: n.location}) AS establecimientos
            WITH tipo, COUNT(tipo) AS numero_establecimientos, establecimientos
            RETURN {
                tipo: tipo,
                numero_establecimientos: numero_establecimientos,
                establecimientos: establecimientos
            } AS tipos_establecimientos
        """,
        columnName: "tipos_establecimientos"
    )
}

The GraphQL Library doesn't support configuration of this - in the context of a query the Cypher is executed in read mode, and in the context of mutations the Cypher is executed in write mode.

This is my main question - why does this procedure require write permissions? This is a Neo4j Labs project which by the looks of it isn't even supported by Neo4j 5 (but I could be wrong), and the GraphQL Library is moving to not support Neo4j 4 soon anyway.

As per my above answer, this is dependent on the query which is being executed.