From 9911a55069ae6e20b6a3c23af1a19b42e5b2022a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=E1=BB=8Bnh=20Duy=20H=C6=B0ng?= <57101685+HUNG-rushb@users.noreply.github.com> Date: Fri, 15 Dec 2023 02:10:34 +0700 Subject: [PATCH] ok --- src/Type_Definitions/Album_Album.js | 6 ++++++ src/resolvers/Query/ALBUM.js | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/Type_Definitions/Album_Album.js b/src/Type_Definitions/Album_Album.js index f6bf715..3220c35 100644 --- a/src/Type_Definitions/Album_Album.js +++ b/src/Type_Definitions/Album_Album.js @@ -5,6 +5,7 @@ const albumDefs = gql` allAlbums: [Album]! userAllAlbum(data: UserAllAlbumInput!): [Album]! albumInfo(data: AlbumInfoInput!): [Post]! + postNotInAlbum(data: NotInAlbumInfoInput!): [Post]! } input UserAllAlbumInput { @@ -17,6 +18,11 @@ const albumDefs = gql` albumId: ID! } + input NotInAlbumInfoInput { + userId: ID! + albumId: ID! + } + extend type Mutation { createAlbum(data: CreateAlbumInput!): Album! diff --git a/src/resolvers/Query/ALBUM.js b/src/resolvers/Query/ALBUM.js index 428f7c1..f13b8ae 100644 --- a/src/resolvers/Query/ALBUM.js +++ b/src/resolvers/Query/ALBUM.js @@ -61,6 +61,16 @@ const albumQuery = { }, }); }, + postNotInAlbum: async (parent, args, info) => { + return await prisma.post.findMany({ + where: { + userId: args.data.userId, + NOT: { + albumId: { has: args.data.albumId }, + }, + }, + }); + }, }; export default albumQuery;