neo4j-graphql / neo4j-graphql-java

Neo4j Labs Project: Pure JVM translation for GraphQL queries and mutations to Neo4j's Cypher
Apache License 2.0
105 stars 49 forks source link

Incorrect mutation translation for IDs with @property #299

Closed mcmathews closed 1 year ago

mcmathews commented 1 year ago

Describe the bug Mutations are not being properly translated to cypher when the ID property includes a @property alias. This affects updates, merges, and deletes on nodes, and adds/deletes on edges.

Test Case

GraphQL schema

type Person {
    id: ID! @property(name: "~id")
    name: String
    actedIn: [Movie!]! @relation(name: "ACTED_IN", direction:OUT)
}

type Movie {
    title: String!
}

GraphQL request

mutation {
  mergePerson(id: "test-id", name: "test-name") {
    id
  }
}

Expected cypher query

MERGE (mergePerson:Person {
    `~id`: $mergePersonId
})
SET mergePerson += {
    name: $mergePersonName
}
WITH mergePerson
RETURN mergePerson {
    id: mergePerson.`~id`
} AS mergePerson

Expected cypher params

{
  "mergePersonId": "test-id",
  "mergePersonName": "test-name"
}

Neo4j test data N/A

Expected GraphQL response N/A

Actual cypher query

MERGE (mergePerson:Person {
    id: $mergePersonId
})
SET mergePerson += {
    name: $mergePersonName
}
WITH mergePerson
RETURN mergePerson {
    id: mergePerson.`~id`
} AS mergePerson

Additional context None