fix: added updated and deleted subscription changes (#24)

This commit is contained in:
Ankit Sridhar
2023-02-27 19:03:48 +05:30
committed by GitHub
parent 1860057a25
commit 292ed87201
3 changed files with 11 additions and 25 deletions

View File

@@ -167,15 +167,8 @@ export class UserEnvironmentsResolver {
resolve: (value) => value, resolve: (value) => value,
}) })
@UseGuards(GqlAuthGuard) @UseGuards(GqlAuthGuard)
userEnvironmentUpdated( userEnvironmentUpdated(@GqlUser() user: User) {
@Args({ return this.pubsub.asyncIterator(`user_environment/${user.uid}/updated`);
name: 'id',
description: 'Environment id',
type: () => ID,
})
id: string,
) {
return this.pubsub.asyncIterator(`user_environment/${id}/updated`);
} }
@Subscription(() => UserEnvironment, { @Subscription(() => UserEnvironment, {
@@ -183,15 +176,8 @@ export class UserEnvironmentsResolver {
resolve: (value) => value, resolve: (value) => value,
}) })
@UseGuards(GqlAuthGuard) @UseGuards(GqlAuthGuard)
userEnvironmentDeleted( userEnvironmentDeleted(@GqlUser() user: User) {
@Args({ return this.pubsub.asyncIterator(`user_environment/${user.uid}/deleted`);
name: 'id',
description: 'Environment id',
type: () => ID,
})
id: string,
) {
return this.pubsub.asyncIterator(`user_environment/${id}/deleted`);
} }
@Subscription(() => Number, { @Subscription(() => Number, {

View File

@@ -369,7 +369,7 @@ describe('UserEnvironmentsService', () => {
); );
return expect(mockPubSub.publish).toHaveBeenCalledWith( return expect(mockPubSub.publish).toHaveBeenCalledWith(
`user_environment/${result.id}/updated`, `user_environment/${result.userUid}/updated`,
result, result,
); );
}); });
@@ -398,7 +398,7 @@ describe('UserEnvironmentsService', () => {
); );
return expect(mockPubSub.publish).toHaveBeenCalledWith( return expect(mockPubSub.publish).toHaveBeenCalledWith(
`user_environment/${result.id}/updated`, `user_environment/${result.userUid}/updated`,
result, result,
); );
}); });
@@ -463,7 +463,7 @@ describe('UserEnvironmentsService', () => {
await userEnvironmentsService.deleteUserEnvironment('abc123', 'env1'); await userEnvironmentsService.deleteUserEnvironment('abc123', 'env1');
return expect(mockPubSub.publish).toHaveBeenCalledWith( return expect(mockPubSub.publish).toHaveBeenCalledWith(
`user_environment/${result.id}/deleted`, `user_environment/${result.userUid}/deleted`,
result, result,
); );
}); });
@@ -557,7 +557,7 @@ describe('UserEnvironmentsService', () => {
await userEnvironmentsService.clearGlobalEnvironments('abc123', 'env1'); await userEnvironmentsService.clearGlobalEnvironments('abc123', 'env1');
return expect(mockPubSub.publish).toHaveBeenCalledWith( return expect(mockPubSub.publish).toHaveBeenCalledWith(
`user_environment/${result.id}/updated`, `user_environment/${result.userUid}/updated`,
result, result,
); );
}); });

View File

@@ -151,7 +151,7 @@ export class UserEnvironmentsService {
}; };
// Publish subscription for environment update // Publish subscription for environment update
await this.pubsub.publish( await this.pubsub.publish(
`user_environment/${updatedUserEnvironment.id}/updated`, `user_environment/${updatedUserEnvironment.userUid}/updated`,
updatedUserEnvironment, updatedUserEnvironment,
); );
return E.right(updatedUserEnvironment); return E.right(updatedUserEnvironment);
@@ -192,7 +192,7 @@ export class UserEnvironmentsService {
// Publish subscription for environment deletion // Publish subscription for environment deletion
await this.pubsub.publish( await this.pubsub.publish(
`user_environment/${deletedUserEnvironment.id}/deleted`, `user_environment/${deletedUserEnvironment.userUid}/deleted`,
deletedUserEnvironment, deletedUserEnvironment,
); );
return E.right(true); return E.right(true);
@@ -253,7 +253,7 @@ export class UserEnvironmentsService {
// Publish subscription for environment update // Publish subscription for environment update
await this.pubsub.publish( await this.pubsub.publish(
`user_environment/${updatedUserEnvironment.id}/updated`, `user_environment/${updatedUserEnvironment.userUid}/updated`,
updatedUserEnvironment, updatedUserEnvironment,
); );
return E.right(updatedUserEnvironment); return E.right(updatedUserEnvironment);