Skip to content

Commit

Permalink
ok
Browse files Browse the repository at this point in the history
  • Loading branch information
HUNG-rushb committed Dec 15, 2023
1 parent 9911a55 commit 588835a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/Type_Definitions/Album_Album.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const albumDefs = gql`
deleteAlbum(data: DeleteAlbumInput!): Album!
deleteAllAlbum: DeleteAllReturnType!
updateAlbum(data: UpdateAlbumInput!): Album!
addNewPhotoToAlbum(data: UpdateAlbumInput!): Album!
}
input CreateAlbumInput {
Expand All @@ -43,7 +43,7 @@ const albumDefs = gql`
input UpdateAlbumInput {
albumId: ID!
name: String!
postIds: [ID]!
}
type Album {
Expand Down
33 changes: 18 additions & 15 deletions src/resolvers/Mutation/album.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,27 @@ const albumMutation = {
return result;
},
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!
updateAlbum: async (parent, args, info) => {
const { updatedUser, ...updateInfo } = args.data;
let result;
try {
updatedUser = await prisma.user.update({
where: {
id: userId,
addNewPhotoToAlbum: async (parent, args, info) => {
const { albumId, postIds } = args.data;

await prisma.post.updateMany({
where: {
id: {
in: postIds,
},
data: {
...updateInfo,
},
data: {
albumId: {
push: albumId,
},
});
} catch (e) {
console.log(e);
throw e;
}
},
});

return updatedUser;
return await prisma.album.findUnique({
where: {
id: albumId,
},
});
},
};

Expand Down

0 comments on commit 588835a

Please sign in to comment.