From 0b9b030cee65b8614f4d85abfaf7d2863581abb4 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Wed, 1 Mar 2023 15:05:41 +0530 Subject: [PATCH] fix: remove update author mutation --- server/schema/comment/comment.datasources.js | 26 -------------------- server/schema/comment/comment.mutation.js | 9 ------- server/schema/comment/comment.resolver.js | 14 ----------- 3 files changed, 49 deletions(-) diff --git a/server/schema/comment/comment.datasources.js b/server/schema/comment/comment.datasources.js index cc5a1b39..740fae1e 100644 --- a/server/schema/comment/comment.datasources.js +++ b/server/schema/comment/comment.datasources.js @@ -74,31 +74,6 @@ const updateContent = async (id, content, session, authToken, mid) => { } }; -const updateAuthor = async (id, authorID, session, authToken, mid) => { - try { - const _author = await userModel.findById(authorID); - if (!_author) { - throw APIError('NOT FOUND', null, 'Invalid Author ID'); - } - - const _comment = await CommentModel.findByIdAndUpdate( - id, - { - author: { - name: _author.fullName, - reference: authorID, - }, - updatedBy: UserSession.valid(session, authToken) ? mid : null, - }, - { new: true } - ); - - return _comment; - } catch (error) { - throw APIError(null, error); - } -}; - const remove = (id) => CommentModel.findByIdAndDelete(id); const CommentDataSources = () => ({ @@ -107,7 +82,6 @@ const CommentDataSources = () => ({ countNumberOfComments, create, updateContent, - updateAuthor, remove, }); diff --git a/server/schema/comment/comment.mutation.js b/server/schema/comment/comment.mutation.js index 2c48bbaa..59e3f819 100644 --- a/server/schema/comment/comment.mutation.js +++ b/server/schema/comment/comment.mutation.js @@ -48,15 +48,6 @@ module.exports = new GraphQLObjectType({ }, resolve: updateCommentContent, }, - updateCommentAuthor: { - description: 'Update Comment by Id', - type: CommentType, - args: { - id: { type: new GraphQLNonNull(GraphQLID) }, - authorID: { type: new GraphQLNonNull(GraphQLID) }, - }, - resolve: updateCommentAuthor, - }, deleteComment: { description: 'Delete comment by Id', type: CommentType, diff --git a/server/schema/comment/comment.resolver.js b/server/schema/comment/comment.resolver.js index b9d3aa10..a5a529a6 100644 --- a/server/schema/comment/comment.resolver.js +++ b/server/schema/comment/comment.resolver.js @@ -72,20 +72,6 @@ module.exports = { throw APIError(null, error); } }, - updateCommentAuthor: async ( - _parent, - { id, authorID }, - { session, authToken, decodedToken, mid, API: { Comment } } - ) => { - try { - await canMutateComment(session, authToken, decodedToken, id, mid, Comment); - const _comment = await Comment.updateAuthor(id, authorID, session, authToken, mid); - - return _comment; - } catch (error) { - throw APIError(null, error); - } - }, updateCommentContent: async ( _parent, { id, content },