refactor: user history resolver changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Args, ID, Mutation, Resolver, Subscription } from '@nestjs/graphql';
|
import { Args, Mutation, Resolver, Subscription } from '@nestjs/graphql';
|
||||||
import { UserHistoryService } from './user-history.service';
|
import { UserHistoryService } from './user-history.service';
|
||||||
import { PubSubService } from '../pubsub/pubsub.service';
|
import { PubSubService } from '../pubsub/pubsub.service';
|
||||||
import { UserHistory } from './user-history.model';
|
import { UserHistory } from './user-history.model';
|
||||||
@@ -63,7 +63,7 @@ export class UserHistoryResolver {
|
|||||||
id: string,
|
id: string,
|
||||||
): Promise<UserHistory> {
|
): Promise<UserHistory> {
|
||||||
const updatedHistory =
|
const updatedHistory =
|
||||||
await this.userHistoryService.starUnstarRequestInHistory(user.uid, id);
|
await this.userHistoryService.toggleHistoryStarStatus(user.uid, id);
|
||||||
if (E.isLeft(updatedHistory)) throwErr(updatedHistory.left);
|
if (E.isLeft(updatedHistory)) throwErr(updatedHistory.left);
|
||||||
return updatedHistory.right;
|
return updatedHistory.right;
|
||||||
}
|
}
|
||||||
@@ -114,15 +114,8 @@ export class UserHistoryResolver {
|
|||||||
resolve: (value) => value,
|
resolve: (value) => value,
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
userHistoryCreated(
|
userHistoryCreated(@GqlUser() user: User) {
|
||||||
@Args({
|
return this.pubsub.asyncIterator(`user_history/${user.uid}/created`);
|
||||||
name: 'userUid',
|
|
||||||
description: 'user uid',
|
|
||||||
type: () => ID,
|
|
||||||
})
|
|
||||||
userUid: string,
|
|
||||||
) {
|
|
||||||
return this.pubsub.asyncIterator(`user_history/${userUid}/created`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscription(() => UserHistory, {
|
@Subscription(() => UserHistory, {
|
||||||
@@ -130,15 +123,8 @@ export class UserHistoryResolver {
|
|||||||
resolve: (value) => value,
|
resolve: (value) => value,
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
userHistoryUpdated(
|
userHistoryUpdated(@GqlUser() user: User) {
|
||||||
@Args({
|
return this.pubsub.asyncIterator(`user_history/${user.uid}/updated`);
|
||||||
name: 'userUid',
|
|
||||||
description: 'user uid',
|
|
||||||
type: () => ID,
|
|
||||||
})
|
|
||||||
userUid: string,
|
|
||||||
) {
|
|
||||||
return this.pubsub.asyncIterator(`user_history/${userUid}/updated`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscription(() => UserHistory, {
|
@Subscription(() => UserHistory, {
|
||||||
@@ -146,14 +132,16 @@ export class UserHistoryResolver {
|
|||||||
resolve: (value) => value,
|
resolve: (value) => value,
|
||||||
})
|
})
|
||||||
@UseGuards(GqlAuthGuard)
|
@UseGuards(GqlAuthGuard)
|
||||||
userHistoryDeleted(
|
userHistoryDeleted(@GqlUser() user: User) {
|
||||||
@Args({
|
return this.pubsub.asyncIterator(`user_history/${user.uid}/deleted`);
|
||||||
name: 'userUid',
|
}
|
||||||
description: 'user uid',
|
|
||||||
type: () => ID,
|
@Subscription(() => Number, {
|
||||||
})
|
description: 'Listen for User History deleted many',
|
||||||
userUid: string,
|
resolve: (value) => value,
|
||||||
) {
|
})
|
||||||
return this.pubsub.asyncIterator(`user_history/${userUid}/deleted`);
|
@UseGuards(GqlAuthGuard)
|
||||||
|
userHistoryDeletedMany(@GqlUser() user: User) {
|
||||||
|
return this.pubsub.asyncIterator(`user_history/${user.uid}/deleted_many`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user