Skip to content

Commit

Permalink
lesson 10c - resolvers for monolith
Browse files Browse the repository at this point in the history
  • Loading branch information
mabuyo committed Jun 11, 2024
1 parent 4ff2118 commit 628662b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions monolith/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ const resolvers = {
},
},
Listing: {
host: ({ hostId }, _, { dataSources }) => {
return dataSources.accountsAPI.getUser(hostId);
host: ({ hostId }) => {
return { id: hostId };
},
overallRating: ({ id }, _, { dataSources }) => {
return dataSources.reviewsDb.getOverallRatingForListing(id);
Expand Down Expand Up @@ -425,8 +425,8 @@ const resolvers = {
checkOutDate: ({ checkOutDate }, _, { dataSources }) => {
return dataSources.bookingsDb.getHumanReadableDate(checkOutDate);
},
guest: ({ guestId }, _, { dataSources }) => {
return dataSources.accountsAPI.getUser(guestId);
guest: ({ guestId }) => {
return { id: guestId };
},
totalPrice: async (
{ listingId, checkInDate, checkOutDate },
Expand All @@ -451,8 +451,14 @@ const resolvers = {
},
},
Review: {
author: ({ authorId }, _, { dataSources }) => {
return dataSources.accountsAPI.getUser(authorId);
author: (review) => {
let role = "";
if (review.targetType === "LISTING" || review.targetType === "HOST") {
role = "Guest";
} else {
role = "Host";
}
return { __typename: role, id: review.authorId, role };
},
},
AmenityCategory: {
Expand Down

0 comments on commit 628662b

Please sign in to comment.