Should we add call subquery to AGE? It will allow Neo4j's GraphQL library to be compatible with AGE.
Data Setup
SELECT * FROM cypher('xyz', $$
CREATE (:Actor{name:'Tom Hanks'})-[:ACTED_IN]->(:Movie{title:'Forrest Gump'})
$$) as (a agtype);
Two uses of call subquery
1)
SELECT * FROM ag_catalog.cypher('xyz', $$
MATCH (this:Movie)
CALL {
WITH this
MATCH (this)<-[this0:ACTED_IN]-(this1:Actor)
WITH ag_catalog.agtype_build_map('name', this1.name) AS this1
RETURN collect(this1) AS var2
}
RETURN ag_catalog.agtype_build_map('title', this.title, 'actors', var2) AS this
$$) as ("?" agtype);
2)
SELECT * FROM ag_catalog.cypher('xyz', $$
UNWIND $create_param0 AS create_var0
CALL {
WITH create_var0
CREATE (create_this1:Movie)
SET
create_this1.title = create_var0.title
WITH create_this1, create_var0
CALL {
WITH create_this1, create_var0
UNWIND create_var0.actors.create AS create_var2
WITH create_var2.node AS create_var3, create_var2.edge AS create_var4, create_this1
CREATE (create_this5:Actor)
SET
create_this5.name = create_var3.name
MERGE (create_this1)<-[create_this6:ACTED_IN]-(create_this5)
RETURN collect(NULL) AS create_var7
}
RETURN create_this1
}
CALL {
WITH create_this1
MATCH (create_this1)<-[create_this8:ACTED_IN]-(create_this9:Actor)
WITH ag_catalog.agtype_build_map('name', create_this9.name) AS create_this9
RETURN collect(create_this9) AS create_var10
}
RETURN collect(ag_catalog.agtype_build_map('title', create_this1.title, 'actors', create_var10)) AS data
$$,
'[ { title: 'Forrest Gump', actors: { create: [{ node: { name: "Tom Hanks" } }] } } ]' -- parameter
) as ("?" agtype);
Should we add call subquery to AGE? It will allow Neo4j's GraphQL library to be compatible with AGE.
Data Setup
Two uses of call subquery
1)
2)
Expected output For both queries: