Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-17-2020 11:46 AM
Hi. I have been successfully defining schemas that use relationships with interfaces but I just tried to do this with a relationship type that has properties and then the schema won't validate.
Example:
Using the schema from the docs with: Person, User, and Actor, etc I want to include the friends relationship as part of the Person Interface but attach a since property to the friends relationship. My approach was this:
interface Person {
id: ID!
name: String
friends: [Friend]
}
type Friend @relation (name: "FRIEND_OF") {
from: Person
to: Person
since: Date
}
type User implements Person {
id: ID!
name: String
friends: [Friend]
screenName: String
reviews: [Review] @relation(name: "WROTE", direction: OUT)
}
type Actor implements Person {
id: ID!
name: String
friends: [Friend]
movies: [Movie] @relation(name: "ACTED_IN", direction: OUT)
}
type Movie {
movieId: ID!
title: String
}
type Review {
rating: Int
created: DateTime
movie: Movie @relation(name: "REVIEWS", direction: OUT)
}
When I run this the schema validator complains that the type User is implementing the Friend relationship but that Friend is defined as having the to and from types as Person. I assumed the validator would resolve the use of types implementing interfaces for these fields. Is there another way to handle this or am I missing something?
Thanks,
Nick
10-19-2020 02:09 PM
You may have to define the relationship as a field on the interface like:
interface Person {
id: ID!
name: String
friends: [Friend] @relation(name: "FRIEND_OF", direction: OUT/IN)
}
Just like you have for your Review relationship. Not sure if that will work but it might.
All the sessions of the conference are now available online