diff --git a/backend/src/schema/resolvers/comments.js b/backend/src/schema/resolvers/comments.js index 7f3b11da4..d2e296596 100644 --- a/backend/src/schema/resolvers/comments.js +++ b/backend/src/schema/resolvers/comments.js @@ -38,22 +38,41 @@ export default { if (!post) { throw new UserInputError(NO_POST_ERR_MESSAGE) } - const comment = await neo4jgraphql(object, params, context, resolveInfo, false) + const commentWithoutRelationships = await neo4jgraphql( + object, + params, + context, + resolveInfo, + false, + ) - await session.run( + let transactionRes = await session.run( ` MATCH (post:Post {id: $postId}), (comment:Comment {id: $commentId}), (author:User {id: $userId}) MERGE (post)<-[:COMMENTS]-(comment)<-[:WROTE]-(author) - RETURN post`, + RETURN comment, author`, { userId: context.user.id, postId, - commentId: comment.id, + commentId: commentWithoutRelationships.id, }, ) - session.close() - return comment + const [commentWithAuthor] = transactionRes.records.map(record => { + return { + comment: record.get('comment'), + author: record.get('author'), + } + }) + + const { comment, author } = commentWithAuthor + + const commentReturnedWithAuthor = { + ...comment.properties, + author: author.properties, + } + session.close() + return commentReturnedWithAuthor }, DeleteComment: async (object, params, context, resolveInfo) => { const comment = await neo4jgraphql(object, params, context, resolveInfo, false) diff --git a/backend/yarn.lock b/backend/yarn.lock index 1a63381d6..426ed0d57 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -3375,13 +3375,8 @@ extsprintf@^1.2.0: faker@Marak/faker.js#master: version "4.1.0" - uid "10bfb9f467b0ac2b8912ffc15690b50ef3244f09" resolved "https://codeload.github.com/Marak/faker.js/tar.gz/10bfb9f467b0ac2b8912ffc15690b50ef3244f09" -"faker@git+https://github.com/Marak/faker.js.git#master": - version "4.1.0" - resolved "git+https://github.com/Marak/faker.js.git#10bfb9f467b0ac2b8912ffc15690b50ef3244f09" - fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" diff --git a/webapp/components/comments/CommentForm/index.vue b/webapp/components/comments/CommentForm/index.vue index f105bd5ff..753d09c13 100644 --- a/webapp/components/comments/CommentForm/index.vue +++ b/webapp/components/comments/CommentForm/index.vue @@ -25,6 +25,8 @@