diff --git a/client/coral-framework/graphql/mutations/index.js b/client/coral-framework/graphql/mutations/index.js index 04dba8402..a67b728e6 100644 --- a/client/coral-framework/graphql/mutations/index.js +++ b/client/coral-framework/graphql/mutations/index.js @@ -17,9 +17,11 @@ export const postComment = graphql(POST_COMMENT, { postItem: ({asset_id, body, parent_id}) => mutate({ variables: { - asset_id, - body, - parent_id + comment: { + asset_id, + body, + parent_id + } }, optimisticResponse: { createComment: { diff --git a/client/coral-framework/graphql/mutations/postComment.graphql b/client/coral-framework/graphql/mutations/postComment.graphql index 110ab4b4e..f98558804 100644 --- a/client/coral-framework/graphql/mutations/postComment.graphql +++ b/client/coral-framework/graphql/mutations/postComment.graphql @@ -1,7 +1,7 @@ #import "../fragments/commentView.graphql" -mutation CreateComment ($asset_id: ID!, $parent_id: ID, $body: String!) { - createComment(asset_id:$asset_id, parent_id:$parent_id, body:$body) { +mutation CreateComment ($comment: CreateCommentInput!) { + createComment(comment: $comment) { comment { ...commentView replyCount diff --git a/graph/resolvers/root_mutation.js b/graph/resolvers/root_mutation.js index 3d5ea9ad9..9d7a1d1e6 100644 --- a/graph/resolvers/root_mutation.js +++ b/graph/resolvers/root_mutation.js @@ -2,7 +2,7 @@ const wrapResponse = require('../helpers/response'); const CommentsService = require('../../services/comments'); const RootMutation = { - createComment(_, {asset_id, parent_id, body}, {mutators: {Comment}}) { + createComment(_, {comment: {asset_id, parent_id, body}}, {mutators: {Comment}}) { return wrapResponse('comment')(Comment.create({asset_id, parent_id, body})); }, createLike(_, {like: {item_id, item_type}}, {mutators: {Action}}) { diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 8b07c2ab2..1b369329f 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -593,6 +593,29 @@ input CreateLikeInput { item_type: ACTION_ITEM_TYPE! } + + +enum TAG { + STAFF + OFF_TOPIC +} + +input CreateCommentInput { + + # The asset id + asset_id: ID! + + # The id of the parent comment + parent_id: ID + + # The body of the comment + body: String! + + # Tags + tags: [TAG] + +} + type CreateLikeResponse implements Response { # The like that was created. @@ -707,7 +730,7 @@ type RemoveCommentTagResponse implements Response { type RootMutation { # Creates a comment on the asset. - createComment(asset_id: ID!, parent_id: ID, body: String!): CreateCommentResponse + createComment(comment: CreateCommentInput!): CreateCommentResponse # Creates a like on an entity. createLike(like: CreateLikeInput!): CreateLikeResponse