-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement creation for feed/graph/namespace
- Loading branch information
Showing
8 changed files
with
196 additions
and
1 deletion.
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,24 @@ | ||
import type { CreateFeedRequest, CreateFeedResult } from '@lens-protocol/graphql'; | ||
import { CreateFeedMutation } from '@lens-protocol/graphql'; | ||
import type { ResultAsync } from '@lens-protocol/types'; | ||
|
||
import type { SessionClient } from '../clients'; | ||
import type { UnauthenticatedError, UnexpectedError } from '../errors'; | ||
|
||
/** | ||
* Create a Feed | ||
* | ||
* ```ts | ||
* const result = await createFeed(sessionClient); | ||
* ``` | ||
* | ||
* @param client - The session client logged as a builder. | ||
* @param request - The mutation request. | ||
* @returns Tiered transaction result. | ||
*/ | ||
export function createFeed( | ||
client: SessionClient, | ||
request: CreateFeedRequest, | ||
): ResultAsync<CreateFeedResult, UnexpectedError | UnauthenticatedError> { | ||
return client.mutation(CreateFeedMutation, { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { CreateGraphRequest, CreateGraphResult } from '@lens-protocol/graphql'; | ||
import { CreateGraphMutation } from '@lens-protocol/graphql'; | ||
import type { ResultAsync } from '@lens-protocol/types'; | ||
|
||
import type { SessionClient } from '../clients'; | ||
import type { UnauthenticatedError, UnexpectedError } from '../errors'; | ||
|
||
/** | ||
* Create a Graph | ||
* | ||
* ```ts | ||
* const result = await createGraph(sessionClient); | ||
* ``` | ||
* | ||
* @param client - The session client logged as a builder. | ||
* @param request - The mutation request. | ||
* @returns Tiered transaction result. | ||
*/ | ||
export function createGraph( | ||
client: SessionClient, | ||
request: CreateGraphRequest, | ||
): ResultAsync<CreateGraphResult, UnexpectedError | UnauthenticatedError> { | ||
return client.mutation(CreateGraphMutation, { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
export * from './account'; | ||
export * from './app'; | ||
export * from './authentication'; | ||
export * from './feed'; | ||
export * from './follow'; | ||
export * from './graph'; | ||
export * from './namespace'; | ||
export * from './post'; | ||
export * from './posts'; | ||
export * from './transactions'; | ||
export * from './timeline'; | ||
export * from './transactions'; |
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,30 @@ | ||
import type { | ||
CreateUsernameNamespaceRequest, | ||
CreateUsernameNamespaceResult, | ||
} from '@lens-protocol/graphql'; | ||
import { CreateUsernameNamespaceMutation } from '@lens-protocol/graphql'; | ||
import type { ResultAsync } from '@lens-protocol/types'; | ||
|
||
import type { SessionClient } from '../clients'; | ||
import type { UnauthenticatedError, UnexpectedError } from '../errors'; | ||
|
||
/** | ||
* Create a Namespace | ||
* | ||
* ```ts | ||
* const result = await createUsernameNamespace(sessionClient, { | ||
* symbol: 'NAME', | ||
* namespace: 'custom-namespace', | ||
* }); | ||
* ``` | ||
* | ||
* @param client - The session client logged as a builder. | ||
* @param request - The mutation request. | ||
* @returns Tiered transaction result. | ||
*/ | ||
export function createUsernameNamespace( | ||
client: SessionClient, | ||
request: CreateUsernameNamespaceRequest, | ||
): ResultAsync<CreateUsernameNamespaceResult, UnexpectedError | UnauthenticatedError> { | ||
return client.mutation(CreateUsernameNamespaceMutation, { 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { FragmentOf } from 'gql.tada'; | ||
import { SelfFundedTransactionRequest, TransactionWillFail } from './fragments'; | ||
import { type RequestOf, graphql } from './graphql'; | ||
|
||
const CreateFeedResponse = graphql( | ||
`fragment CreateFeedResponse on CreateFeedResponse { | ||
__typename | ||
hash | ||
}`, | ||
); | ||
export type CreateFeedResponse = FragmentOf<typeof CreateFeedResponse>; | ||
|
||
const CreateFeedResult = graphql( | ||
`fragment CreateFeedResult on CreateFeedResult { | ||
...on CreateFeedResponse { | ||
...CreateFeedResponse | ||
} | ||
...on SelfFundedTransactionRequest { | ||
...SelfFundedTransactionRequest | ||
} | ||
...on TransactionWillFail { | ||
...TransactionWillFail | ||
} | ||
}`, | ||
[CreateFeedResponse, SelfFundedTransactionRequest, TransactionWillFail], | ||
); | ||
export type CreateFeedResult = FragmentOf<typeof CreateFeedResult>; | ||
|
||
export const CreateFeedMutation = graphql( | ||
`mutation CreateFeed($request: CreateFeedRequest!) { | ||
value: createFeed(request: $request) { | ||
...CreateFeedResult | ||
} | ||
}`, | ||
[CreateFeedResult], | ||
); | ||
export type CreateFeedRequest = RequestOf<typeof CreateFeedMutation>; |
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,37 @@ | ||
import type { FragmentOf } from 'gql.tada'; | ||
import { SelfFundedTransactionRequest, TransactionWillFail } from './fragments'; | ||
import { type RequestOf, graphql } from './graphql'; | ||
|
||
const CreateGraphResponse = graphql( | ||
`fragment CreateGraphResponse on CreateGraphResponse { | ||
__typename | ||
hash | ||
}`, | ||
); | ||
export type CreateGraphResponse = FragmentOf<typeof CreateGraphResponse>; | ||
|
||
const CreateGraphResult = graphql( | ||
`fragment CreateGraphResult on CreateGraphResult { | ||
...on CreateGraphResponse { | ||
...CreateGraphResponse | ||
} | ||
...on SelfFundedTransactionRequest { | ||
...SelfFundedTransactionRequest | ||
} | ||
...on TransactionWillFail { | ||
...TransactionWillFail | ||
} | ||
}`, | ||
[CreateGraphResponse, SelfFundedTransactionRequest, TransactionWillFail], | ||
); | ||
export type CreateGraphResult = FragmentOf<typeof CreateGraphResult>; | ||
|
||
export const CreateGraphMutation = graphql( | ||
`mutation CreateGraph($request: CreateGraphRequest!) { | ||
value: createGraph(request: $request) { | ||
...CreateGraphResult | ||
} | ||
}`, | ||
[CreateGraphResult], | ||
); | ||
export type CreateGraphRequest = RequestOf<typeof CreateGraphMutation>; |
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,37 @@ | ||
import type { FragmentOf } from 'gql.tada'; | ||
import { SelfFundedTransactionRequest, TransactionWillFail } from './fragments'; | ||
import { type RequestOf, graphql } from './graphql'; | ||
|
||
const CreateNamespaceResponse = graphql( | ||
`fragment CreateNamespaceResponse on CreateNamespaceResponse { | ||
__typename | ||
hash | ||
}`, | ||
); | ||
export type CreateNamespaceResponse = FragmentOf<typeof CreateNamespaceResponse>; | ||
|
||
const CreateUsernameNamespaceResult = graphql( | ||
`fragment CreateUsernameNamespaceResult on CreateUsernameNamespaceResult { | ||
...on CreateNamespaceResponse { | ||
...CreateNamespaceResponse | ||
} | ||
...on SelfFundedTransactionRequest { | ||
...SelfFundedTransactionRequest | ||
} | ||
...on TransactionWillFail { | ||
...TransactionWillFail | ||
} | ||
}`, | ||
[CreateNamespaceResponse, SelfFundedTransactionRequest, TransactionWillFail], | ||
); | ||
export type CreateUsernameNamespaceResult = FragmentOf<typeof CreateUsernameNamespaceResult>; | ||
|
||
export const CreateUsernameNamespaceMutation = graphql( | ||
`mutation CreateUsernameNamespace($request: CreateUsernameNamespaceRequest!) { | ||
value: createUsernameNamespace(request: $request) { | ||
...CreateUsernameNamespaceResult | ||
} | ||
}`, | ||
[CreateUsernameNamespaceResult], | ||
); | ||
export type CreateUsernameNamespaceRequest = RequestOf<typeof CreateUsernameNamespaceMutation>; |