Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement missing mutations for publications #1004

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>;
Loading