diff --git a/backend/src/resolvers/comments.js b/backend/src/resolvers/comments.js
index 5ab20cf46..4542c075a 100644
--- a/backend/src/resolvers/comments.js
+++ b/backend/src/resolvers/comments.js
@@ -2,24 +2,11 @@ import { neo4jgraphql } from 'neo4j-graphql-js'
export default {
Mutation: {
- CreateComment: async (object, params, context, resolveInfo) => {
- const { postId } = params
-
- const comment = await neo4jgraphql(object, params, context, resolveInfo, true)
-
- const session = context.driver.session()
- const transactionRes = await session.run(`
- MATCH (post:Post {id: $postId}), (comment:Comment {id: $commentId})
- MERGE (post)<-[:COMMENTS]-(comment)
- RETURN comment {.id, .content}`, {
- postId,
- commentId: comment.id
- }
- )
-
- session.close()
-
- return comment
+ CreateComment: (object, params, context, resolveInfo) => {
+ return neo4jgraphql(object, params, context, resolveInfo, false)
+ },
+ AddPostComments: (object, params, context, resolveInfo) => {
+ return neo4jgraphql(object, params, context, resolveInfo, false)
}
}
}
diff --git a/backend/src/resolvers/comments.spec.js b/backend/src/resolvers/comments.spec.js
index e17f94ec9..2fcd7245f 100644
--- a/backend/src/resolvers/comments.spec.js
+++ b/backend/src/resolvers/comments.spec.js
@@ -19,8 +19,8 @@ afterEach(async () => {
describe('CreateComment', () => {
const mutation = `
- mutation($id: ID!, $postId: ID!, $content: String!) {
- CreateComment(id: $id, postId: $postId, content: $content) {
+ mutation($id: ID!, $content: String!) {
+ CreateComment(id: $id, content: $content) {
id
content
}
@@ -29,8 +29,7 @@ describe('CreateComment', () => {
describe('unauthenticated', () => {
it('throws authorization error', async () => {
variables = {
- id: 'c1',
- postId: 'p1',
+ id: 'c1',
content: "I'm not authorised to comment"
}
client = new GraphQLClient(host)
@@ -46,9 +45,8 @@ describe('CreateComment', () => {
})
it('creates a post', async () => {
- variables = {
- id: 'c1',
- postId: 'p1',
+ variables = {
+ id: 'c1',
content: "I'm authorised to comment"
}
const expected = {
diff --git a/backend/src/schema.graphql b/backend/src/schema.graphql
index 6c35e082d..94e28d0d7 100644
--- a/backend/src/schema.graphql
+++ b/backend/src/schema.graphql
@@ -27,7 +27,6 @@ type Mutation {
enable(id: ID!): ID
reward(fromBadgeId: ID!, toUserId: ID!): ID
unreward(fromBadgeId: ID!, toUserId: ID!): ID
- CreateComment(id: ID!, postId: ID!, content: String!) : Comment
"Shout the given Type and ID"
shout(id: ID!, type: ShoutTypeEnum): Boolean! @cypher(statement: """
MATCH (n {id: $id})<-[:WROTE]-(wu:User), (u:User {id: $cypherParams.currentUserId})
diff --git a/backend/src/seed/factories/comments.js b/backend/src/seed/factories/comments.js
index 29d0722b7..b6ada7ac9 100644
--- a/backend/src/seed/factories/comments.js
+++ b/backend/src/seed/factories/comments.js
@@ -4,7 +4,6 @@ import uuid from 'uuid/v4'
export default function (params) {
const {
id = uuid(),
- postId = uuid(),
content = [
faker.lorem.sentence(),
faker.lorem.sentence()
@@ -15,7 +14,6 @@ export default function (params) {
mutation {
CreateComment(
id: "${id}",
- postId: "${postId}",
content: "${content}"
) { id, content }
}
diff --git a/webapp/graphql/AddPostComments.js b/webapp/graphql/AddPostComments.js
new file mode 100644
index 000000000..ab9ef8ca5
--- /dev/null
+++ b/webapp/graphql/AddPostComments.js
@@ -0,0 +1,18 @@
+import gql from 'graphql-tag'
+
+export default app => {
+ return {
+ AddPostComments: gql(`
+ mutation($from: _CommentInput!, $to: _PostInput!) {
+ AddPostComments(from: $from, to: $to) {
+ from {
+ id
+ }
+ to {
+ id
+ }
+ }
+ }
+ `)
+ }
+}
diff --git a/webapp/pages/post/_id/_slug/index.vue b/webapp/pages/post/_id/_slug/index.vue
index 8af07bc26..ef1121031 100644
--- a/webapp/pages/post/_id/_slug/index.vue
+++ b/webapp/pages/post/_id/_slug/index.vue
@@ -117,11 +117,11 @@
v-model="value"
/>
+