Hi. Is there an easy way with prisma-bindings to u...
# orm-help
m
Hi. Is there an easy way with prisma-bindings to update connections without having to loop & filter in my resolver? For instance, I have a Post type that has a Pictures relation. In updating Post, users may want to add and/or remove connected Pictures. I understand that I could make some calls to the server, do some good ole loopin' and reducin', but figured maybe there was a ready-to-cook version?
n
have a look at the nested mutations
connect
and
disconnect
m
@nilan, totally understood and using connect and disconnect is the current plan (which are great), but, given that the 'update' mutation in the scenario above acts like a batch mutation with respect to Pictures, some actor has to decide whether 'connect' or 'disconnect' is the appropriate action to take. Wasn't sure if y'all had something amazing that would do that logic (could be a cool feature), or if I needed to implement it somewhere.
In other words, I'm imagining a situation in which a user creates a Post with several pictures (1, 2, 3, 4, 5). User then determines that user likes photos 2,3, and 4, but not 1, 5. User sends update mutation replacing 1 with 6, and 2 with 7 (so, after update, Post should be connected to 2, 3, 4, 6, and 7). To make it more interesting, maybe 6 exists and can be connected, but 7 is new and needs to be created. Currently, for createPost, client is sending an array of pictures, which I then loop over in server side resolver to (1) take care of ancillary business (e.g., generating signed upload/download URLs, etc.,) and (2) appropriately prepare input object for data: pictures: create. This works like a charm for the 'createPost' scenario, but is not as awesome for the updatePost scenario.
n
I proposed a new nested mutation
replace
for to-many relations. Please leave an upvote & subscribe here: https://github.com/graphcool/prisma/issues/2036 🙂
👍 1
m
Will do.