Skip to content

Commit

Permalink
featL added misc, publications and post mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinesamuel committed Nov 18, 2024
1 parent 0c19743 commit 659b7c1
Show file tree
Hide file tree
Showing 8 changed files with 1,066 additions and 1,060 deletions.
16 changes: 7 additions & 9 deletions src/managers/misc/misc.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ export class MiscellaneousManager extends BaseManager {
}

/**
*
* ===================MUTATIONS===================
*
*/
*
* ===================MUTATIONS===================
*
*/

/**
* Follow tags
Expand All @@ -84,11 +84,11 @@ export class MiscellaneousManager extends BaseManager {

/**
* Unfollow tags
*
*
* @param input - The UnFollowTag input.
*
*
* @returns The tag details.
*/
*/
async unfollowTags(input: UnfollowTagsInput) {
const res = await this.makeRequest<{ unfollowTag: UnfollowTagsPayload }>(
'unfollowTags',
Expand All @@ -97,6 +97,4 @@ export class MiscellaneousManager extends BaseManager {
);
return res.unfollowTag;
}


}
56 changes: 28 additions & 28 deletions src/managers/misc/misc.mutations.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import { gql } from 'graphql-request';

export const FOLLOW_TAGS_MUTATION = gql`
mutation followTags($input: FollowTagsInput!) {
followTags(input: $input) {
tags {
id
name
slug
logo
tagline
info {
markdown
mutation followTags($input: FollowTagsInput!) {
followTags(input: $input) {
tags {
id
name
slug
logo
tagline
info {
markdown
}
followersCount
postsCount
}
followersCount
postsCount
}
}
}
`
`;

export const UNFOLLOW_TAGS_MUTATION = gql`
mutation followTags($input: UnfollowTagsInput!) {
unfollowTags(input: $input) {
tags {
id
name
slug
logo
tagline
info {
markdown
mutation followTags($input: UnfollowTagsInput!) {
unfollowTags(input: $input) {
tags {
id
name
slug
logo
tagline
info {
markdown
}
followersCount
postsCount
}
followersCount
postsCount
}
}
}
`
`;
85 changes: 47 additions & 38 deletions src/managers/posts/post.manager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
import type { PublishPostInput, AddPostToSeriesInput, UpdatePostInput, RemovePostInput, LikePostInput, LikePostPayload, RemovePostPayload, UpdatePostPayload, AddPostToSeriesPayload, PublishPostPayload } from './../../generated/gqlQueryTypes';
import type {
PublishPostInput,
AddPostToSeriesInput,
UpdatePostInput,
RemovePostInput,
LikePostInput,
LikePostPayload,
RemovePostPayload,
UpdatePostPayload,
AddPostToSeriesPayload,
PublishPostPayload,
} from './../../generated/gqlQueryTypes';
import type { HashnodeSDKClient } from '../../client';
import { BaseManager } from '../base.manager';
import {
Expand Down Expand Up @@ -201,93 +212,91 @@ export class PostManager extends BaseManager {

/**
* Publish a post
*
*
* @param {PublishPostInput} input - The post to be published
*
*
* @returns The new post
*/
*/
async publishPost(input: PublishPostInput) {
const res = await this.makeRequest<{ publishedpost: PublishPostPayload }>(
'publishPost',
PUBLISH_POST_MUTATION,
{
input
}
)
return res.publishedpost.post
input,
},
);
return res.publishedpost.post;
}

/**
* Add a post to a series
*
*
* @param {AddPostToSeriesInput} input - The input of the post to be added to the series
*
*
* @return The series
*/
*/
async addPostToSeries(input: AddPostToSeriesInput) {
const res = await this.makeRequest<{ series: AddPostToSeriesPayload }>(
'addPostToSeries',
ADD_POST_TO_SERIES_MUTATION,
{
input
}
)
return res.series
input,
},
);
return res.series;
}

/**
* Updates a post
*
*
* @param {UpdatePostInput} input - The input of the post to be updated
*
*
* @return The updated post
*/
*/
async updatePost(input: UpdatePostInput) {
const res = await this.makeRequest<{ updatedPost: UpdatePostPayload }>(
'updatePost',
UPDATE_POST_MUTATION,
{
input
}
)
return res.updatedPost
input,
},
);
return res.updatedPost;
}

/**
* Remove a post
*
*
* @param {RemovePostInput} input - The input of the post to be removed
*
*
* @return The removed post
*/
*/
async removePost(input: RemovePostInput) {
const res = await this.makeRequest<{ removedPost: RemovePostPayload }>(
'removePost',
REMOVE_POST_MUTATION,
{
input
}
)
return res.removedPost
input,
},
);
return res.removedPost;
}

/**
* Like a post
*
*
* @param {LikePostInput} input - The input of the post to be liked
*
*
* @return The liked post
*/
*/
async likePost(input: LikePostInput) {
const res = await this.makeRequest<{ likedPost: LikePostPayload }>(
'likePost',
LIKE_POST_MUTATION,
{
input
}
)
return res.likedPost
input,
},
);
return res.likedPost;
}


}
Loading

0 comments on commit 659b7c1

Please sign in to comment.