The following code that can be found in the documentation seems to be wrong:
type Organization @entity {
id: ID!
name: String!
members: [UserOrganization]! @derivedFrom(field: "user")
}
type User @entity {
id: ID!
name: String!
organizations: [UserOrganization!] @derivedFrom(field: "organization")
}
type UserOrganization @entity {
id: ID! # Set to `${user.id}-${organization.id}`
user: User!
organization: Organization!
}
And should have the @derivedFrom
parameter switched like this:
type Organization @entity {
id: ID!
name: String!
members: [UserOrganization]! @derivedFrom(field: "organization")
}
type User @entity {
id: ID!
name: String!
organizations: [UserOrganization!] @derivedFrom(field: "user")
}
type UserOrganization @entity {
id: ID! # Set to `${user.id}-${organization.id}`
user: User!
organization: Organization!
}