Can anyone point me to a pattern that would allow ...
# prisma-whats-new
r
Can anyone point me to a pattern that would allow me to (for example) update a comment that was associated with a post, where I don't have the commentId - but do have the postId?
s
hmm interesting. So the
Post
would have an array of `Comment`s in a field right?
n
what else do you have about the comment, @rem? currently, the workflow is to somehow obtain this comment id
in the future, a nested upsert mutation would be the better approach: https://github.com/graphcool/framework/issues/127
r
The authenticated user - which is (supposed) to be unique – so there can only be 1 comment per user on the post
"the workflow is to somehow obtain this comment id" - ah, poop. I was hoping to avoid that, but I guess it'll do 🙂
n
are you using an API Gateway? you could write a specialized mutation that abstracts that logic away from the client
s
what’s a nested upsert mutation exactly? @nilan
r
@nilan no, not using the API gateway logic thingy yet - though I saw something similar that also mentioned the API Gateway, so I'll take a look when the dust has settled on the dev. Cheers.
n
in this case, it would look somewhat like this:
Copy code
updatePost(
  id: $postId
  update_comment: {
    filter: {
      author: {
        id: $userId
      }
    }
    comment: {
      text: $newText
    }
  }
) {
  id
}
just came up with that syntax, the idea is that you use
updatePost
to update a connected comment, that you select by some condition