From 1ffd583f53d7dbd82c8e33fbd8798555fdfd8c92 Mon Sep 17 00:00:00 2001 From: Srishty M Date: Mon, 23 Oct 2023 19:12:01 +0530 Subject: [PATCH 1/4] feat: added mutation to create comment --- client/src/graphql/mutations/comment/addComment.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 client/src/graphql/mutations/comment/addComment.js diff --git a/client/src/graphql/mutations/comment/addComment.js b/client/src/graphql/mutations/comment/addComment.js new file mode 100644 index 00000000..da21a3d9 --- /dev/null +++ b/client/src/graphql/mutations/comment/addComment.js @@ -0,0 +1,12 @@ +import { gql } from '@apollo/client'; + +export default gql` + mutation createComment($content: String!, $authorID: ID!, parentID: ID!, parentType: String!) { + createComment(content: $content, id: $authorID, parentID: $parentID, parentType: $parentType) { + content + id + parentID + parentType + } + } +`; From 53633be23e9be2eb900169781ce36fcb948ad10b Mon Sep 17 00:00:00 2001 From: Srishty M Date: Tue, 24 Oct 2023 02:31:28 +0530 Subject: [PATCH 2/4] feat: wrote code for adding comment --- client/src/graphql/mutations/comment/addComment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/graphql/mutations/comment/addComment.js b/client/src/graphql/mutations/comment/addComment.js index da21a3d9..d53f4df9 100644 --- a/client/src/graphql/mutations/comment/addComment.js +++ b/client/src/graphql/mutations/comment/addComment.js @@ -1,6 +1,6 @@ import { gql } from '@apollo/client'; -export default gql` +export default addComment = gql` mutation createComment($content: String!, $authorID: ID!, parentID: ID!, parentType: String!) { createComment(content: $content, id: $authorID, parentID: $parentID, parentType: $parentType) { content From 2daca0eebf1664cfc5f65e1737a04add29c394bf Mon Sep 17 00:00:00 2001 From: Srishty M Date: Wed, 31 Jan 2024 15:01:01 +0530 Subject: [PATCH 3/4] feat: added queries to fetch comments --- client/src/graphql/queries/comments/getCommentByID | 9 +++++++++ client/src/graphql/queries/comments/getListOfComments.js | 9 +++++++++ client/src/pages/article/[...article].jsx | 1 + client/src/screens/Article.js | 3 ++- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 client/src/graphql/queries/comments/getCommentByID create mode 100644 client/src/graphql/queries/comments/getListOfComments.js diff --git a/client/src/graphql/queries/comments/getCommentByID b/client/src/graphql/queries/comments/getCommentByID new file mode 100644 index 00000000..50031eed --- /dev/null +++ b/client/src/graphql/queries/comments/getCommentByID @@ -0,0 +1,9 @@ +import { gql } from '@apollo/client'; + +export default getCommentByID = gql` + query getCommentById($id: ID!) { + getListOfComments(ids: $id) { + id + } + } +`; diff --git a/client/src/graphql/queries/comments/getListOfComments.js b/client/src/graphql/queries/comments/getListOfComments.js new file mode 100644 index 00000000..bfc9395e --- /dev/null +++ b/client/src/graphql/queries/comments/getListOfComments.js @@ -0,0 +1,9 @@ +import { gql } from '@apollo/client'; + +export default getListOfComments = gql` + query getListOfComments($ids: [ID]!, $limit: Int) { + getListOfComments(ids: $ids, limit: $limit) { + ids + } + } +`; diff --git a/client/src/pages/article/[...article].jsx b/client/src/pages/article/[...article].jsx index 0bac74ab..4c55ed17 100644 --- a/client/src/pages/article/[...article].jsx +++ b/client/src/pages/article/[...article].jsx @@ -16,6 +16,7 @@ import getArticleByID from '../../graphql/queries/article/getArticleByID'; import getArticleByOldID from '../../graphql/queries/article/getArticleByOldID'; import getArticleLink, { getArticleSlug } from '../../utils/getArticleLink'; import Custom500 from '../500'; +import Comment from '../../components/article/comments/Comment'; function ArticlePage({ article, isError }) { const { isFallback } = useRouter(); diff --git a/client/src/screens/Article.js b/client/src/screens/Article.js index c1d6c15c..bc6bc180 100644 --- a/client/src/screens/Article.js +++ b/client/src/screens/Article.js @@ -16,6 +16,7 @@ import ArticleTags from '../components/article/Tags'; import RecommendedArticles from '../components/article/RecommendedArticles'; import SidePanel from '../components/article/SidePanel'; import SidePanelMobile from '../components/article/SidePanelMobile'; +import Comment from '../components/article/comments/Comment'; // Assets import theme from '../config/themes/light'; @@ -35,7 +36,7 @@ function Article({ article }) {
- {/* */} + From 913caf807407688d58089e350b4cf58843a41c07 Mon Sep 17 00:00:00 2001 From: Srishty M Date: Wed, 31 Jan 2024 15:02:54 +0530 Subject: [PATCH 4/4] feat: added queries to fetch comments --- .../queries/comments/{getCommentByID => getCommentByID.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/src/graphql/queries/comments/{getCommentByID => getCommentByID.js} (100%) diff --git a/client/src/graphql/queries/comments/getCommentByID b/client/src/graphql/queries/comments/getCommentByID.js similarity index 100% rename from client/src/graphql/queries/comments/getCommentByID rename to client/src/graphql/queries/comments/getCommentByID.js