Hi! i want to update a node related to another nod...
# prisma-whats-new
s
Hi! i want to update a node related to another node. it could be Address node nested into Contact node... can i update it using the updateContact mutation? i thought so but i'm having troubles
n
@sunrising no you cannot update the related Address through
updateContact
you can only create a new Address or link the Contact to another Address using
updateContact
if you want to update the Address, you have to first query its id and then use the
updateAddress
mutation 🙂
s
ok, good but one thing i noticed:
i tried to update the address using the contact update mutation and this is not ok, well but anyway another address is created in the db with a new Id, completely unrelated to everything, is it correct?
i was expecting a change on the address node and this is not possible, ok, but maybe i was expecting a new address node related to the contact one, or an error
n
this is not correct but a fix should be rolled out soon 🙂 We're already working on that
s
so: or an update on the old one, or a new relation with a new node or error
ok, thanks! what behaviour do you think it's going to have in the end? (so i can code that way 🙂 )
n
The old address will be not related to anything, the new address will be related to the contact
s
ok, so the "cleaning" of the old unrelated data is up to me, just to ask
n
Yep! I think it's cleaner to just update the old address 🙂
instead of creating a new one
depending on what you need
s
wait a minute 🙂 isn't it the opposite of "The old address will be not related to anything, the new address will be related to the contact" that you said 1 minute ago?
n
Well you asked about the behaviour of using
updateContract
with the nested
address
object
This is the behaviour:
The old address will be not related to anything, the new address will be related to the contact
However, I think using
updateAddress
is better, because it doesn't leave an old address node lying around that would be "obsolete"
s
ok, got it, thanks!
n
🙂 no worries!