Creating a relationship between two nodes but the second node can have any of two predefined labels in neo4j-graphql-js


(Shreyansh Zazz) #1

Suppose I want to define a relationship like the following :

a:University -[ENTRY]-> b:Department 
OR
a:University -[ENTRY]-> p:Position

How to do this with neo4j-graphql-js ?


(Michael Hunger) #2

My main recommendation would be to use properly descriptive relationship-types.

Otherwise you can use two custom mutations that use a @cypher directive for creating either of these.


(Shreyansh Zazz) #3

Okay, let's say I defined the two mutations as below,
addPositionEntry()
addDepartmentEntry()

Now coming back to GraphQL schema level,

University{
    entry: // Here I want the relationship data to come whether it's from addPositionEntry or addDepartmentEntry
}

How should I do this?