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.
Thank you all for answering the question.
The solution which a came up with was the following:
distribucion_establecimientos: [TipoEstablecimiento]! @cypher(
statement: """
MATCH (this)-[]-(s:Seccion_Censal)<-[:ESTABLECIMIENTO_PERTENECE]-(n)-[:TAGS]-(t:OSMTags)
WHERE ('OSMNode' in labels(n) or 'OSMWay' in labels(n)) AND ((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
optional match (n)-[:FIRST_NODE]->(:OSMWayNode)-[:NODE]-(d:OSMNode)
WITH CASE
WHEN t.amenity IS NULL THEN t.leisure
ELSE t.amenity
END AS tipo,
collect({nombre: t.name, punto:
CASE
WHEN d.location IS NULL then n.location
ELSE d.location
END
}) AS establecimientos
WITH tipo, size(establecimientos) AS numero_establecimientos, establecimientos
RETURN {tipo:tipo,
numero_establecimientos: numero_establecimientos,
establecimientos: establecimientos} as tipos_establecimientos
""",
columnName: "tipos_establecimientos"
)