From 4804ccc88474bf3748e4395c2b455d1f545229dd Mon Sep 17 00:00:00 2001 From: andrewquang512 Date: Sat, 4 Nov 2023 17:28:45 +0700 Subject: [PATCH] Update createComment --- src/Type_Definitions/Comment_Comment.js | 6 ++++-- src/Type_Definitions/Image_Image.js | 4 +--- src/resolvers/Mutation/comment.js | 4 ++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Type_Definitions/Comment_Comment.js b/src/Type_Definitions/Comment_Comment.js index ab39e79..dc744e4 100644 --- a/src/Type_Definitions/Comment_Comment.js +++ b/src/Type_Definitions/Comment_Comment.js @@ -51,8 +51,8 @@ const commentDefs = gql` input CreateCommentInput { content: String! userId: ID! - postId: ID! - storyId: ID! + postId: ID + storyId: ID parentCommentId: ID } @@ -76,6 +76,8 @@ const commentDefs = gql` votes: Int! children: [Comment] + + userVotePost: [String]! } `; diff --git a/src/Type_Definitions/Image_Image.js b/src/Type_Definitions/Image_Image.js index 51cf913..f776236 100644 --- a/src/Type_Definitions/Image_Image.js +++ b/src/Type_Definitions/Image_Image.js @@ -4,7 +4,7 @@ import commonDefs from './Common_Common.js' const imageDefs = gql` extend type Query { allImages: [Image]! - exploreImages(data: ExploreImagesInput): ImagePagination! + exploreImages(data: ExploreImagesInput, limit: Int, after: String): ImagePagination! } type ImagePagination { @@ -25,8 +25,6 @@ const imageDefs = gql` input ExploreImagesInput{ categoryId: String! - limit: Int - after: String } type Image { diff --git a/src/resolvers/Mutation/comment.js b/src/resolvers/Mutation/comment.js index ba32fe5..e464558 100644 --- a/src/resolvers/Mutation/comment.js +++ b/src/resolvers/Mutation/comment.js @@ -12,6 +12,10 @@ const commentMutation = { createComment: async (parent, args, info) => { const { content, postId, storyId, userId, parentCommentId = null } = args.data + if (!storyId && !postId) { + throw Error('At least storyId or postId provided') + } + let comment; try { comment = await prisma.comment.create({