Skip to content

Commit

Permalink
fix: remove update author mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
Shurtu-gal committed Mar 1, 2023
1 parent 3447d74 commit 0b9b030
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 49 deletions.
26 changes: 0 additions & 26 deletions server/schema/comment/comment.datasources.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => ({
Expand All @@ -107,7 +82,6 @@ const CommentDataSources = () => ({
countNumberOfComments,
create,
updateContent,
updateAuthor,
remove,
});

Expand Down
9 changes: 0 additions & 9 deletions server/schema/comment/comment.mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 0 additions & 14 deletions server/schema/comment/comment.resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 0b9b030

Please sign in to comment.