-
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.
* Implement fetchApp Co-authored-by: Cesare Naldi <[email protected]>
- Loading branch information
1 parent
bd01617
commit 8817c09
Showing
10 changed files
with
81 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { App } from '@lens-protocol/graphql'; | ||
import { AppQuery } from '@lens-protocol/graphql'; | ||
import type { ResultAsync } from '@lens-protocol/types'; | ||
|
||
import type { AppRequest } from '@lens-protocol/graphql'; | ||
import type { AnyClient, SessionClient } from '../clients'; | ||
import type { UnexpectedError } from '../errors'; | ||
|
||
/** | ||
* Fetch an App. | ||
* | ||
* Using a {@link SessionClient} will yield {@link App#operations} | ||
* | ||
* ```ts | ||
* const result = await fetchApp(anyClient, { | ||
* address: evmAddress('0xe2f2a5C287993345a840db3B0845fbc70f5935a5'), | ||
* }); | ||
* ``` | ||
* | ||
* @param client - Any Lens client. | ||
* @param request - The App query request. | ||
* @returns The App or `null` if it does not exist. | ||
*/ | ||
export function fetchApp( | ||
client: AnyClient, | ||
request: AppRequest, | ||
): ResultAsync<App | null, UnexpectedError> { | ||
return client.query(AppQuery, { 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,12 @@ | ||
import { App } from './fragments'; | ||
import { type RequestOf, graphql } from './graphql'; | ||
|
||
export const AppQuery = graphql( | ||
`query App($request: AppRequest!) { | ||
value: app(request: $request) { | ||
...App | ||
} | ||
}`, | ||
[App], | ||
); | ||
export type AppRequest = RequestOf<typeof AppQuery>; |
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
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 |
---|---|---|
@@ -1,16 +1,41 @@ | ||
import type { FragmentOf } from 'gql.tada'; | ||
import { graphql } from '../graphql'; | ||
|
||
export const AppMetadata = graphql( | ||
`fragment AppMetadata on AppMetadata { | ||
__typename | ||
description | ||
developer | ||
logo | ||
name | ||
platforms | ||
privacyPolicy | ||
termsOfService | ||
url | ||
}`, | ||
); | ||
export type AppMetadata = FragmentOf<typeof AppMetadata>; | ||
|
||
export const App = graphql( | ||
`fragment App on App { | ||
__typename | ||
address | ||
graphAddress | ||
sponsorshipAddress | ||
defaultFeedAddress | ||
namespaceAddress | ||
treasuryAddress | ||
createdAt | ||
metadata { | ||
...AppMetadata | ||
} | ||
}`, | ||
[AppMetadata], | ||
); | ||
export type App = FragmentOf<typeof App>; | ||
|
||
export const Feed = graphql( | ||
`fragment Feed on Feed { | ||
address | ||
address | ||
}`, | ||
); | ||
export type Feed = FragmentOf<typeof App>; |
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