Hi @jackson1 ,
Great idea, really simple and seems incredibly obvious now. Thank you!
I'm wondering if you can help me take this one step further, because I'm a little confused, hope you don't mind the lengthy post and thank you again and in advance!
The next step I would want to do with this is figure out how to create the Vote
nodes, I don't think I want to create them for every Topic & Fact combo unless they're necessary, because it would end up with far too many unused nodes (Vote nodes without votes).
If I were to do this with GraphQL, how would you recommend i approach this? Would you make each vote ID the concatenation of Topic.id and Fact.id, so I can check for its existence more easily? And if it doesn't exist then create it, if it does exist then connect the user node to the Vote node?
And if so, how might you approach all of this with GraphQL, I'm really confused and trying to simplify it with the newly introduced connectOrCreate mutation.
Do I approach it from:
createVotes()
or updateVotes()
or updateUsers()
or updateFacts()
I can't figure out what my top-level would be, this is one attempt but I couldn't get it working. Here I was approaching it through the Facts. Finding the Fact
node, then looking to see if I could find a Vote node with a specific ID (here's one of the spots where I'm confused, I would need to know the ID as you can't query inside connectOrCreate
by any other property (so do I just concatenation Thing.id + Fact.id?). Then if that node didn't I was creating it and connecting everything all up. Is this reasonable?
updateFacts(
where: { id: "5d081f2e-7663-4ac1-9c18-f087c35b7042"},
connectOrCreate: {
votes: {
where: { node: { id: "lmnop"}},
onCreate: {
node: {
type: "factVote",
thing: { connect: { where: { node: { id: "21732715-2aa2-4c4b-9c45-ea4985f2113c" }}}},
detail: { connect: { where: { node: { id: "5d081f2e-7663-4ac1-9c18-f087c35b7042" }}}},
user_votes: { connect: {where: {node: { id: "YSCbEHFxm0gnXOPEKmRb8WUVO7j2"}}}}
}
}
}
}
)```