From 757e2d9fcef0f83b52d3b30e8885da2a850969cf Mon Sep 17 00:00:00 2001
From: tkt <37575408+tktcorporation@users.noreply.github.com>
Date: Mon, 10 Oct 2022 11:59:04 +0000
Subject: [PATCH] :sparkles: finish
https://redwoodjs.com/docs/tutorial/chapter6/comment-form
---
web/src/components/Article/Article.tsx | 2 +-
web/src/components/CommentForm/CommentForm.tsx | 2 +-
web/src/components/CommentsCell/CommentsCell.tsx | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/web/src/components/Article/Article.tsx b/web/src/components/Article/Article.tsx
index 6aa0cbf18..48654900c 100644
--- a/web/src/components/Article/Article.tsx
+++ b/web/src/components/Article/Article.tsx
@@ -24,7 +24,7 @@ const Article = ({ article, summary = false }) => {
)}
diff --git a/web/src/components/CommentForm/CommentForm.tsx b/web/src/components/CommentForm/CommentForm.tsx
index cc3010935..659e6db97 100644
--- a/web/src/components/CommentForm/CommentForm.tsx
+++ b/web/src/components/CommentForm/CommentForm.tsx
@@ -40,7 +40,7 @@ const CommentForm = ({ postId }: Props) => {
setHasPosted(true)
toast.success('Thank you for your comment!')
},
- refetchQueries: [{ query: CommentsQuery }],
+ refetchQueries: [{ query: CommentsQuery, variables: { postId } }],
})
const onSubmit: SubmitHandler = (input) => {
createComment({ variables: { input: { postId, ...input } } })
diff --git a/web/src/components/CommentsCell/CommentsCell.tsx b/web/src/components/CommentsCell/CommentsCell.tsx
index 024e862e5..0d3113604 100644
--- a/web/src/components/CommentsCell/CommentsCell.tsx
+++ b/web/src/components/CommentsCell/CommentsCell.tsx
@@ -5,8 +5,8 @@ import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web'
import Comment from 'src/components/Comment'
export const QUERY = gql`
- query CommentsQuery {
- comments {
+ query CommentsQuery($postId: Int!) {
+ comments(postId: $postId) {
id
name
body