MCPcopy Create free account
hub / github.com/dailydotdev/apps / normalizeFeedV2Edge

Function normalizeFeedV2Edge

packages/shared/src/graphql/feed.ts:165–211  ·  view source on GitHub ↗
(
  edge: Connection<FeedV2Item>['edges'][number],
)

Source from the content-addressed store, hash-verified

163});
164
165const normalizeFeedV2Edge = (
166 edge: Connection<FeedV2Item>['edges'][number],
167): Connection<FeedApiItem>['edges'][number] | null => {
168 const { node } = edge;
169
170 if (isFeedV2PostItem(node)) {
171 if (!node.post) {
172 throw new Error('feedV2 post item is missing post');
173 }
174
175 const feedMeta = node.feedMeta ?? node.post.feedMeta ?? null;
176
177 return {
178 ...edge,
179 node: {
180 itemType: 'post',
181 feedMeta,
182 post: {
183 ...node.post,
184 ...(feedMeta ? { feedMeta } : {}),
185 // Only the explain query selects it, so null still means the card
186 // is shown in Explain mode, just without an explanation.
187 ...('explain' in node ? { explain: node.explain ?? null } : {}),
188 },
189 },
190 };
191 }
192
193 if (isFeedV2HighlightsItem(node)) {
194 if (!node.highlights?.length) {
195 return null;
196 }
197
198 return {
199 ...edge,
200 node: {
201 itemType: 'highlight',
202 feedMeta: node.feedMeta ?? null,
203 highlights: node.highlights,
204 },
205 };
206 }
207
208 warnUnsupportedFeedItem(getGraphqlTypename(node) ?? 'unknown');
209
210 return null;
211};
212
213export const normalizeFeedPage = (
214 data: FeedData | FeedItemData | FeedV2Data,

Callers 1

normalizeFeedPageFunction · 0.85

Calls 4

isFeedV2PostItemFunction · 0.85
isFeedV2HighlightsItemFunction · 0.85
warnUnsupportedFeedItemFunction · 0.85
getGraphqlTypenameFunction · 0.85

Tested by

no test coverage detected