I’m not so sure about how to build my GraphQL schema relationship.
An org can have many members
, each member is a virtual type (@embedded
) which defines the user and the role it has within the org.
What I want to do is:
- List all the members of an org.
- List all the orgs a member belongs to.
The 1) is straightforward.
The 2) is a bit harder, I’m not sure if I should use an index, or store the information as User.orgs
, within the User entity too (2 ways, but data duplication)
enum OrgMemberRole{
admin
editor
}
type Org @collection(
name: "Orgs"
){
id: ID!
members: [OrgMember]!
}
type OrgMember @embedded{
user: User!
role: OrgMemberRole!
}
type User @collection(
name: "Users"
){
id: ID!
"""TODO Is something like this necessary?"""
orgs: [Org] @relation(
name: "userOrgs"
)
}