Describe the bug
As in the title - invalid mutation query for one-to-many relations: auto-generated add and delete mutations generate invalid Cypher query.
Test Case
package org.example.graphql
import org.neo4j.graphql.SchemaBuilder
import org.neo4j.graphql.Translator
fun main() {
val sdl = /* GraphQL scheme */
val schema = SchemaBuilder.buildSchema(sdl)
val translator = Translator(schema)
val mutation = /* GraphQL mutation */
println(translator.translate(mutation, params = HashMap<String, Any>().also {
it["id"] = 0
it["belongsTo"] = listOf(1, 2, 3)
}))
}
GraphQL schema
type Item {
_id: ID!
name: String!
belongsTo: [Category!]! @relation(name: "BelongsTo")
}
type Category {
_id: ID!
name: String!
}
MATCH (from:Item)
WHERE id(from) = toInteger($id)
MATCH (to:Category)
WHERE id(to) in $belongsTo // <---- here
MERGE (from)-[:BelongsTo]->(to)
WITH DISTINCT from AS addItemBelongsTo
RETURN addItemBelongsTo {
_id: id(addItemBelongsTo)
} AS addItemBelongsTo
Generated cypher query
MATCH (from:Item)
WHERE id(from) = toInteger($id)
MATCH (to:Category)
WHERE id(to) = toInteger($belongsTo) // <---- invalid, $belongsTo is a list, not just a single integer
MERGE (from)-[:BelongsTo]->(to)
WITH DISTINCT from AS addItemBelongsTo
RETURN addItemBelongsTo {
_id: id(addItemBelongsTo)
} AS addItemBelongsTo
Additional contextneo4j-graphql-java version: 1.7.0 (also tested 1.6.0 and 1.5.0 - the same issue)
Describe the bug As in the title - invalid mutation query for one-to-many relations: auto-generated add and delete mutations generate invalid Cypher query.
Test Case
GraphQL schema
GraphQL request
Expected cypher query
Generated cypher query
Additional context
neo4j-graphql-java
version: 1.7.0 (also tested 1.6.0 and 1.5.0 - the same issue)