Created by and Edited by Releationships

I'm attempting to add created by and an edited by relationships on each of my nodes. My first attempt looked like this:

type Created @relation(name: "CREATED_BY"){
  from: User
  to: Tract, Well, SWD, Operator
  date: Date
}

Which of course doesn't work because of the multiple types. Is it possible to do something like this in order to create relationships to many different types of nodes or do I need to set this individually for each type of node I'll have to make relationships to? i.e.

type Created @relation(name: "CREATED_BY"){
  from: User
  to: Tract
  date: Date
}
type Created @relation(name: "CREATED_BY"){
  from: User
  to: SWD
  date: Date
}

etc. for every type of node in my graph?

One option might be to use multiple node labels and create the Created type for the top level node label. Fore example, if you added a "Resource" node label to every Tract, Well, SWD, and Operator node (manually, using Cypher) then you could just define

type Create @relation(name: "CREATED_BY") {
  from: User
  to: Resource
  date: Date
}

We don't currently have a great way to represent multiple node labels in our GraphQL integrations, but this might work as a workaround.

Could you create a Github issue for this use case so we can track it: Issues · neo4j-graphql/neo4j-graphql-js · GitHub

1 Like