-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
114 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import type { | ||
Post, | ||
TimelineHighlightsRequest, | ||
TimelineItem, | ||
TimelineRequest, | ||
} from '@lens-protocol/graphql'; | ||
import { TimelineHighlightsQuery, TimelineQuery } from '@lens-protocol/graphql'; | ||
import type { ResultAsync } from '@lens-protocol/types'; | ||
|
||
import type { AnyClient } from '../clients'; | ||
import type { UnexpectedError } from '../errors'; | ||
import type { Paginated } from '../types'; | ||
|
||
/** | ||
* Fetch timeline from an account. | ||
* | ||
* ```ts | ||
* const result = await fetchTimeline(anyClient, { | ||
* account: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'), | ||
* }); | ||
* ``` | ||
* | ||
* @param client - Any Lens client. | ||
* @param request - The query request. | ||
* @returns The list of timeline items. | ||
*/ | ||
export function fetchTimeline( | ||
client: AnyClient, | ||
request: TimelineRequest, | ||
): ResultAsync<Paginated<TimelineItem> | null, UnexpectedError> { | ||
return client.query(TimelineQuery, { request }); | ||
} | ||
|
||
/** | ||
* Fetch fetchTimelineHighlights from an account. | ||
* | ||
* ```ts | ||
* const result = await fetchTimelineHighlights(anyClient, { | ||
* account: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'), | ||
* }); | ||
* ``` | ||
* | ||
* @param client - Any Lens client. | ||
* @param request - The query request. | ||
* @returns The list of highlights post for an account. | ||
*/ | ||
export function fetchTimelineHighlights( | ||
client: AnyClient, | ||
request: TimelineHighlightsRequest, | ||
): ResultAsync<Paginated<Post> | null, UnexpectedError> { | ||
return client.query(TimelineHighlightsQuery, { request }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import type { FragmentOf } from 'gql.tada'; | ||
import { PaginatedResultInfo, Post } from './fragments'; | ||
import { type RequestOf, graphql } from './graphql'; | ||
|
||
const TimelineItem = graphql( | ||
`fragment TimelineItem on TimelineItem { | ||
__typename | ||
id | ||
primary { | ||
...Post | ||
} | ||
comments { | ||
...Post | ||
} | ||
reposts { | ||
...Post | ||
} | ||
}`, | ||
[Post], | ||
); | ||
export type TimelineItem = FragmentOf<typeof TimelineItem>; | ||
|
||
export const TimelineQuery = graphql( | ||
`query Timeline($request: TimelineRequest!) { | ||
value: timeline(request: $request) { | ||
__typename | ||
items { | ||
...TimelineItem | ||
} | ||
pageInfo { | ||
...PaginatedResultInfo | ||
} | ||
} | ||
}`, | ||
[TimelineItem, PaginatedResultInfo], | ||
); | ||
export type TimelineRequest = RequestOf<typeof TimelineQuery>; | ||
|
||
export const TimelineHighlightsQuery = graphql( | ||
`query TimelineHighlights($request: TimelineHighlightsRequest!) { | ||
value: timelineHighlights(request: $request) { | ||
__typename | ||
items { | ||
...Post | ||
} | ||
pageInfo { | ||
...PaginatedResultInfo | ||
} | ||
} | ||
}`, | ||
[Post, PaginatedResultInfo], | ||
); | ||
export type TimelineHighlightsRequest = RequestOf<typeof TimelineHighlightsQuery>; |