Skip to content

Commit

Permalink
Setup ImageComments
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Dec 19, 2023
1 parent 6643d17 commit 937d191
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/api/db/models/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export class ImageModel {

await image.save();

return { message: 'Images Deleted' };
return { comments: image.comments };
} catch (err) {
// if error is uncontrolled, throw new ApolloError
if (err instanceof ApolloError) throw err;
Expand All @@ -360,7 +360,7 @@ export class ImageModel {

await image.save();

return comment;
return { comments: image.comments };
} catch (err) {
// if error is uncontrolled, throw new ApolloError
if (err instanceof ApolloError) throw err;
Expand Down Expand Up @@ -390,7 +390,7 @@ export class ImageModel {
await operation(input);
const image = await ImageModel.queryById(input.imageId, context);

return image.comments.pop();
return { comments: image.comments };
} catch (err) {
// if error is uncontrolled, throw new ApolloError
if (err instanceof ApolloError) throw err;
Expand Down
4 changes: 0 additions & 4 deletions src/api/type-defs/payloads/ImageCommentPayload.js

This file was deleted.

4 changes: 4 additions & 0 deletions src/api/type-defs/payloads/ImageCommentsPayload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default `
type ImageCommentsPayload {
comments: [ImageComment]
}`;
6 changes: 3 additions & 3 deletions src/api/type-defs/root/Mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ export default `
createImage(input: CreateImageInput!): CreateImagePayload
deleteImages(input: DeleteImagesInput!): StandardErrorPayload
createImageComment(input: CreateImageCommentInput!): ImageCommentPayload
updateImageComment(input: UpdateImageCommentInput!): ImageCommentPayload
deleteImageComment(input: DeleteImageCommentInput!): StandardPayload
createImageComment(input: CreateImageCommentInput!): ImageCommentsPayload
updateImageComment(input: UpdateImageCommentInput!): ImageCommentsPayload
deleteImageComment(input: DeleteImageCommentInput!): ImageCommentsPayload
createUser(input: CreateUserInput!): StandardPayload
updateUser(input: UpdateUserInput!): StandardPayload
Expand Down

0 comments on commit 937d191

Please sign in to comment.