schema design question: say I have a type/model ca...
# prisma-whats-new
s
schema design question: say I have a type/model called
Game
, and I have a property on it called
Similar
which I want to be an array of other `Game`s that are similar. How do I set up that self-referencing relationship? When I add it as a 1 to many relationship, it automatically recreates my
Similar
prop to 2 new props called:
games1
and
games2
m
I don’t know if this will help you but this is how I set up a User model with a list of their family members:
Copy code
type User @model {
  id: ID! @isUnique
  family: Family @relation(name: "FamilyMembers")
}

type Family @model {
  id: ID! @isUnique
  members: [User!]! @relation(name: "FamilyMembers")
}
That’s probably not what you’re looking for though huh
s
yes, I was trying to avoid having to have another "bridge" type/model
m
Is the idea that the game similarities are computed, or are they modified / added by users?
s
they're added by user (admin really)
we specify that game A is similar to games D, R, Z
and so on
m
Gotcha
s
so when a user is playing Game A he sees a list of similar games he might like
m
I’m pretty new to the graphcool framework, but for that relation I don’t know if there’s another way to express that relationship without adding an in-between model. Seems like you should be able to though…
s
right, same thought here, and I'm also new to graphcool
m
you don’t know how to do ‘computed’ fields do you? like if you have a user model with a first and last name, and you want a
fullName
field that just combines them, do you know if that’s doable with graphcool?
s
Hi Steve, I think Mike is correct in creating a bridge table 😉
👍 1
s
looks like it's a new feature that doesn't yet exist maybe
m
Yeah I saw this but it wasn’t clear to me if anything changed since Graphcool Framework was released
but yeah, looks like it’s in the pipeline
s
@Mike Gallagher so when you do the user/family thing like you're doing, how do you initially create the family?
and add the users to it
m
It’s just going to be added by the users themselves
for now we’re just keeping it really simple
s
FYI, I ended up posting my question to the forum and got a reply: