diff --git a/server/src/api/feed/feed.graphql b/server/src/api/feed/feed.graphql index b52fa7cf..72c2310d 100644 --- a/server/src/api/feed/feed.graphql +++ b/server/src/api/feed/feed.graphql @@ -77,6 +77,7 @@ type Query { feeds(first: Int, cursor: String): IFeeds alarms: [Alarm] alarmCount: Int! + feed(feedId: Int!): IFeed } type Mutation { diff --git a/server/src/api/feed/feed.resolvers.ts b/server/src/api/feed/feed.resolvers.ts index 42c4c6d0..3fa0df45 100644 --- a/server/src/api/feed/feed.resolvers.ts +++ b/server/src/api/feed/feed.resolvers.ts @@ -34,7 +34,8 @@ import { QueryResolvers, QueryFeedsArgs, MutationWriteCommentArgs, - Alarm + Alarm, + QueryFeedArgs } from '../../types'; const DEFAUT_MAX_DATE = '9999-12-31T09:29:26.050Z'; @@ -71,7 +72,7 @@ const createImages = async (pubsub, email, feedId, files) => { const publishingFeed = async (pubsub, feedId, email) => { const registerdFeed = await requestDB(GET_NEW_FEED, { feedId, - useremail: email + userEmail: email }); const parsedRegisterdFeed = parseResultRecords(registerdFeed); @@ -279,6 +280,18 @@ const queryResolvers: QueryResolvers = { const [parsedAlarmCount] = parseResultRecords(result); return Number(parsedAlarmCount.alarmCount); + }, + feed: async (_, { feedId }: QueryFeedArgs, { req }): Promise => { + isAuthenticated(req); + const userEmail = req.email; + + const feed = await requestDB(GET_NEW_FEED, { + feedId, + userEmail + }); + const [parsedFeed] = parseResultRecords(feed); + + return parsedFeed; } }; diff --git a/server/src/schema/feed/query.ts b/server/src/schema/feed/query.ts index 88101ab8..424c8272 100644 --- a/server/src/schema/feed/query.ts +++ b/server/src/schema/feed/query.ts @@ -30,7 +30,7 @@ OPTIONAL MATCH (feed)<-[:HAS]-(img:Image) WITH searchUser, feed, COLLECT(DISTINCT likeUser) AS cp , COLLECT(com) as comments, COLLECT(DISTINCT img) as imgs where ID(feed) = {feedId} RETURN searchUser , feed, ID(feed) as feedId , length(cp) AS totallikes, imgs as imglist, -length(filter(x IN cp WHERE x.email= {useremail} )) AS hasLiked, comments +length(filter(x IN cp WHERE x.email= {userEmail} )) AS hasLiked, comments order by feed.createdAt desc `;