cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Using ID in update mutation?

li3zhang
Node Link

The generated mutation will use the first field listed in schema as the identifier for the mutation, eg

type Person {
  username: String
  name: String
  group: String
  email: String
}

will generate

UpdatePerson(
username: String!
name: String
group: String
email: String
): Person

which will create the cypher query
MATCH (p:Person) WHERE p.username = $username ...

However, for my use case, none of these fields are unique, and I would like this mutation to match by the neo4j assigned node ID (and apoc.uuid is not ideal: https://github.com/neo4j/neo4j/issues/12428)

2 REPLIES 2

MuddyBootsCode
Graph Steward

You can always create your own ID field and use whatever identifier you want. You can then exclude that type from the auto generated mutations and make your own resolvers, etc.

Can confirm this, sometimes a call to apoc.create.uuid() is enough and sometimes it creates more hassle than needed because you need the id locally as well. In that case it is better to generate it yourself and pass it to cypher as an additional property.