Skip to content

Commit

Permalink
Fix categoryId undefined issue to explore Image
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewquang512 committed Nov 11, 2023
1 parent 46efd87 commit 403ae3f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/resolvers/Query/IMAGE.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ const imageQuery = {
* @param {*} info
*/
exploreImages: async (parent, args, info) => {
const { categoryId, } = args.data;
const { after, limit = DEFAULT_LIMIT } = args;

const [referencePost, initImages] = await prisma.$transaction([
prisma.post.findFirst({
where: {
categoryId: {
has: categoryId,
},
...(args.data?.categoryId && {
categoryId: {
has: args.data?.categoryId || undefined,
},
}),
image: {
isNot: null,
},
Expand Down Expand Up @@ -119,8 +120,6 @@ const imageQuery = {
endCursor: nodes.length === 0 ? '' : nodes.slice(-1)[0].cursor,
},
};

return result;
},
};

Expand Down

0 comments on commit 403ae3f

Please sign in to comment.