Skip to content

Commit

Permalink
Implement missing mutations for publications
Browse files Browse the repository at this point in the history
  • Loading branch information
juangm committed Dec 9, 2024
1 parent 9dcd3b3 commit 7a5f816
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
67 changes: 67 additions & 0 deletions packages/client/src/actions/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@ import type {
DeletePostRequest,
DeletePostResult,
EditPostRequest,
HideReplyRequest,
PostResult,
UndoBookmarkPostRequest,
UndoReactionRequest,
UndoReactionResult,
UnhideReplyRequest,
} from '@lens-protocol/graphql';
import {
AddReactionMutation,
BookmarkPostMutation,
DeletePostMutation,
EditPostMutation,
HideReplyMutation,
PostMutation,
ReportPostMutation,
RepostMutation,
UndoBookmarkPostMutation,
UndoReactionMutation,
UnhideReplyMutation,
} from '@lens-protocol/graphql';
import type { ResultAsync } from '@lens-protocol/types';

import type { ReportPostRequest } from '@lens-protocol/graphql';
import type { SessionClient } from '../clients';
import type { UnauthenticatedError, UnexpectedError } from '../errors';

Expand Down Expand Up @@ -189,3 +195,64 @@ export function undoBookmarkPost(
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(UndoBookmarkPostMutation, { request });
}

/**
* Hide a reply.
*
* ```ts
* const result = await hideReply(sessionClient, {
* post: post.id,
* });
* ```
*
* @param client - The session client.
* @param request - The mutation request.
* @returns void
*/
export function hideReply(
client: SessionClient,
request: HideReplyRequest,
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(HideReplyMutation, { request });
}

/**
* Unhide a reply.
*
* ```ts
* const result = await unhideReply(sessionClient, {
* post: post.id,
* });
* ```
*
* @param client - The session client.
* @param request - The mutation request.
* @returns void
*/
export function unhideReply(
client: SessionClient,
request: UnhideReplyRequest,
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(UnhideReplyMutation, { request });
}

/**
* Report a post
*
* ```ts
* const result = await reportPost(sessionClient, {
* reason: "SCAM",
* post: post.id,
* });
* ```
*
* @param client - The session client.
* @param request - The mutation request.
* @returns void
*/
export function reportPost(
client: SessionClient,
request: ReportPostRequest,
): ResultAsync<void, UnauthenticatedError | UnexpectedError> {
return client.mutation(ReportPostMutation, { request });
}
21 changes: 21 additions & 0 deletions packages/graphql/src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,24 @@ export const DeletePostMutation = graphql(
[DeletePostResult],
);
export type DeletePostRequest = RequestOf<typeof DeletePostMutation>;

export const HideReplyMutation = graphql(
`mutation HideReply($request: HideReplyRequest!) {
value: hideReply(request: $request)
}`,
);
export type HideReplyRequest = RequestOf<typeof HideReplyMutation>;

export const UnhideReplyMutation = graphql(
`mutation UnhideReply($request: UnhideReplyRequest!) {
value: unhideReply(request: $request)
}`,
);
export type UnhideReplyRequest = RequestOf<typeof UnhideReplyMutation>;

export const ReportPostMutation = graphql(
`mutation ReportPost($request: ReportPostRequest!) {
value: reportPost(request: $request)
}`,
);
export type ReportPostRequest = RequestOf<typeof ReportPostMutation>;

0 comments on commit 7a5f816

Please sign in to comment.