neo4j-graphql-js
neo4j-graphql-js copied to clipboard
apoc generated from graphql query is not correct
I have a query defined as
byParent(id: Int): [movie]
@cypher(
statement: "MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=$id RETURN c"
)
and a graphql query of
query {
byParent(id: 108) {
_id
}
}
this generated
WITH apoc.cypher.runFirstColumn("MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=$id RETURN c", {id:$id}, True)
and returns nothing. but if I hardcode $id to say, 108. i get expected results. similar to this query below that works in desktop browser
CALL apoc.cypher.run("MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=108 RETURN c", {id:108})
work in the desktop browser and so does
MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=108 RETURN c
What is the correct way to get apoc to translate this graphql query / can i add apoc to the gql schema definitions like the apoc procedures added in.
byParent(id: Int): [movie]
@cypher(
statement: "CALL apoc.cypher.run('MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=$id RETURN c', {id:$id})"
)
would be great but I know is not a solution
@adamclark64 Can you share the full generated Cypher query and the Cypher parameters as well (should be logged together)?
graphql query
{
byParent(id: 108) {
_id
}
}
outputs this in the console
WITH apoc.cypher.runFirstColumn("MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=$id RETURN c", {id:$id}, True) AS x UNWIND x AS movie
RETURN movie {_id: ID(movie)} AS movie SKIP $offset
{ offset: 0, first: -1, id: 108 }
The query below works in the neo4j browser when I swap out the id like {id:108} but not sure why the output above returns nothing
RETURN apoc.cypher.runFirstColumn("MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=$id RETURN c", {id:108}, True)
the above seems to be only a partial query, it misses the params, and the "true"
WITH apoc.cypher.runFirstColumn("MATCH (movie:movie)-->(c:movie) WHERE ID(movie)=$id RETURN c", {id:$id}, True) AS x UNWIND x AS movie
RETURN movie {_id: ID(movie)} AS movie SKIP $offset
{ offset: 0, first: -1, id: 108 }
https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608