If I try this, I get an error: ``` updatePost(id: ...
# prisma-whats-new
r
If I try this, I get an error:
Copy code
updatePost(id: $postId, comments: [{ author: $author, content: $content }]) {
  ...
}
The error is
The field 'post' on type 'Comment' is required. Performing this mutation would violate the constraint
a
Try this:
Copy code
createComment(postId: "<post_id>"){id}
Add
postId: "<post_id>"
to your createComment
r
I got errors when I did that saying that postId was not part of PostcommentsComment
I’ve found that if I just add comments separately (and when I add them I specify their parent post) then things work quite well. For now I’m experimenting with that
a
Adding to one side of the relation is enough
After creating the comment with the
postId
, the comment should appear in the post
r
Yes, I think that’s what I didn’t originally realise. It’s working well, though I couldn’t get it working adding a comment inline with updatePost
a
Yes, they already have a feature request for this: https://github.com/graphcool/feature-requests/issues/127
r
Ah brilliant, nice find. Thanks
n
@rajit the error occurs because of the comments that are already connected to the post. running this mutation would first disconnect the existing ones and then connect the new ones.