Skip to content

Commit

Permalink
Update getComments Input Params
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewquang512 committed Nov 4, 2023
1 parent bc2a5c7 commit 458e536
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
8 changes: 2 additions & 6 deletions src/Type_Definitions/Comment_Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const commentDefs = gql`
}
extend type Query {
getCommentsByPostId(data: GetCommentsByPostIdInput): CommentPagination!
getCommentsByStoryId(data: GetCommentsByStoryIdInput): CommentPagination!
getCommentsByPostId(data: GetCommentsByPostIdInput, limit: Int, after: String): CommentPagination!
getCommentsByStoryId(data: GetCommentsByStoryIdInput, limit: Int, after: String): CommentPagination!
}
type CommentPagination {
Expand All @@ -32,14 +32,10 @@ const commentDefs = gql`
input GetCommentsByPostIdInput {
postId: ID!
limit: Int
after: String
}
input GetCommentsByStoryIdInput {
storyId: ID!
limit: Int
after: String
}
enum voteCommentAction {
Expand Down
12 changes: 7 additions & 5 deletions src/resolvers/Query/COMMENT.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ const commentQuery = {
/**
*
* @param {*} parent
* @param {{data: {postId: string, limit: number, after: string}}} args
* @param {{data: {postId: string}, limit: number, after: string}} args
* @param {*} info
* @returns
*/
getCommentsByPostId: async (parent, args, info) => {
const { postId, after, limit } = args.data;
const { postId } = args.data;
const { after, limit } = args;

const [result, count] = await prisma.$transaction([
prisma.comment.findMany({
Expand Down Expand Up @@ -61,19 +62,20 @@ const commentQuery = {
/**
*
* @param {*} parent
* @param {{data: {storyId: string, limit: number, after: string}}} args
* @param {{data: {storyId: string}, limit: number, after: string}} args
* @param {*} info
* @returns
*/
getCommentsByStoryId: async (parent, args, info) => {
const { postId, after, limit } = args.data;
const { storyId } = args.data;
const { after, limit } = args;

const [result, count] = await prisma.$transaction([
prisma.comment.findMany({
take: limit || DEFAULT_LIMIT,
skip: 1,
where: {
storyId: postId,
storyId: storyId,
},
include: {
children: {
Expand Down

0 comments on commit 458e536

Please sign in to comment.