I'm having difficulty knowing how to write my data/Schema structure and would appreciate any recommendations. If you could solve the question on bottom that would be super helpful!
I am using GraphCool and have 4 Schema
's:
User
, Parameter
, Industry
, and Post
.
User
's choose manyIndustry
's from a list. They can change their choices when ever they want.User
's have multipleParameter
's andPost
's, and eachParameter
andPost
has one associated Industry.- Some of the
Parameter
's andPost
's are given to the user by default. TheUser
will be able to make their own as well. - As my app grows, the default
Parameter
's andPost
's will change, and I would like all current customers to see this change (which is why I'm not sure how to hard code it).
In Summary. New User
's need to be given these default Post
's, Industry
's, and Parameter
s.
This is what I have so far. I was thinking I could "autoload" them by querying for default === true
and then writing those to any new User
's. But then if I update the default list, it wouldn't get added to existing users.
type User @model {
id: ID! @isUnique
industries: [Industry!]! @relation(name: "UserIndustries")
posts: [SocialPost!]! @relation(name: "UserPosts")
parameters: [Parameter!]! @relation(name: "UserParameters")
email: String @isUnique
}
type Parameter @model {
id: ID! @isUnique
parameter: String!
response: String!
user: User @relation(name: "UserParameters")
industry: Industry! @relation(name: "ParameterIndustry")
default: Boolean @defaultValue(value: false)
}
type SocialPost @model {
id: ID! @isUnique
message: String!
user: User @relation(name: "UserPosts")
industries: Industry! @relation(name: "SocialPostIndustry")
default: Boolean! @defaultValue(value: false)
}
type Industry @model {
id: ID! @isUnique
default: Boolean! @defaultValue(value: false)
industry: String!
users: [User!]! @relation(name: "UserIndustries")
posts: [SocialPost!]! @relation(name: "SocialPostIndustry")
parameters: [Parameter!]! @relation(name: "ParameterIndustry")
}
A key question that would help solve this. If I have a @relation
between User
and Parameter
, and I want every user to have said Parameter
but I want the response: value
value of that Parameter
to be different for each user, how do I do that??