Closed muhajirdev closed 2 years ago
@muhajirframe : I would to the following here:
upsertUser
to create a user if it does not exist yet. I would leave the update params for this mutation empty as you do not want to update something.Hey @mavilein . Thanks for the answer.
I tried that way, it does works! thanks.
Wondering if the nested mutation could work that way too?
@muhajirframe : Yes. Your idea for the nested createOrConnect
is really neat! Thanks for proposing this 🙏
Hey guys, suppose I have data model like this.
Suppose I have this message data in this form
I want to record that message in database. And create new user with that authorId, if it doesn’t exist yet.
Sometime one message and another message have same
authorId
. That’s why I checkuserExist
first. But, when I run recordMessage(message), alot of times. Sometime it result in race condition, it says user doesn’t exist yet. But when we’re creating new author, I gotUnique constraint
Error. Which means there’s already user with thatauthorId
right?How do you guys handle this situation?
Is there any plan in the future for something like this:
Similar to upsert pattern
or
Some ORM have this feature, like http://docs.sequelizejs.com/manual/tutorial/models-usage.html#-findorcreate-search-for-a-specific-element-or-create-it-if-not-available .
Well, I conclude the paint point here is that
when creating new data that depends on another node, but you're not sure that node already exist or not
.Thanks