Skip to content

Commit

Permalink
Update createComment
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewquang512 committed Nov 4, 2023
1 parent 2da7bf4 commit 4804ccc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/Type_Definitions/Comment_Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const commentDefs = gql`
input CreateCommentInput {
content: String!
userId: ID!
postId: ID!
storyId: ID!
postId: ID
storyId: ID
parentCommentId: ID
}
Expand All @@ -76,6 +76,8 @@ const commentDefs = gql`
votes: Int!
children: [Comment]
userVotePost: [String]!
}
`;

Expand Down
4 changes: 1 addition & 3 deletions src/Type_Definitions/Image_Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -25,8 +25,6 @@ const imageDefs = gql`
input ExploreImagesInput{
categoryId: String!
limit: Int
after: String
}
type Image {
Expand Down
4 changes: 4 additions & 0 deletions src/resolvers/Mutation/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 4804ccc

Please sign in to comment.