Table of Contents
type User {
name:String
referredBy: Referral @relation(direction: OUT)
referred:[Referral] @relation(direction: IN)
}
type Referral @relation (name:"REFERRED_BY", from:"user", to: "referredBy" ) {
user:User
referredBy:User
referralDate:String
}
GraphQL-Query
{user(name:"Jane") {
name
referredBy { referralDate referredBy {name} }
referred { referralDate user {name} }
} }
Cypher params
{"userName":"Jane"}
Cypher
MATCH (user:User) WHERE user.name = $userName RETURN user { .name, referredBy:[(user)-[userReferredBy:REFERRED_BY]->(userReferredByReferredBy:User) | userReferredBy { .referralDate, referredBy:userReferredByReferredBy { .name } }][0], referred:[(user)<-[userReferred:REFERRED_BY]-(userReferredUser:User) | userReferred { .referralDate, user:userReferredUser { .name } }] } AS user