Trying to figure out what the most efficient way t...
# prisma-whats-new
s
Trying to figure out what the most efficient way to update multiple nodes at once would be. Say the user changes a value for a parent model and then I want to recalculate a field for each node of a child model (one to many relation).
n
@sebastien there's currently no built-in way to do updates on many nodes at once
s
Thanks @nilan for the quick answer! So I guess if I find myself really needing to do this I would have to recursively run multiple mutation queries? I assume that this could be pretty bad in terms of performance, right?
If it’s something that you think will be added in the near future for sure, I’ll probably just wait and finish implementing that feature when this type of mutation is available.
n
It's something we want to add for sure, but there's no timeline yet - also I'm not sure it'll fit your needs. The
updateAll
mutation that we're thinking of is handy if you need to update all nodes specified by the usual filter syntax with the same update
say, publish all posts that are older than 2 months
in your case it sounds like you need different values for most nodes
s
Thanks! Very good to know about deleteAll & updateAll. Yes, in my case, every node that match the filter would be updated with different values, say the result of running
doSomethingWithOldValue(modifier, oldValues)
n
then I'd recommend doing multiple mutations in a single GraphQL requests instead
s
Thanks so much, that makes sense! Now I’ll just have to figure out how to create such multi-mutation request using Apollo for Angular. It seems like Apollo for React has something to compose queries or mutations, but I’m not seeing anything similar for Angular.
n
Hum I'm actually not sure about a great approach here