Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

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

Ankit Sridhar292ed872013f
diff --git a/packages/hoppscotch-backend/src/user-environment/user-environments.resolver.ts b/packages/hoppscotch-backend/src/user-environment/user-environments.resolver.ts
index cccdf11cd..dba74eefd 100644
--- a/packages/hoppscotch-backend/src/user-environment/user-environments.resolver.ts
+++ b/packages/hoppscotch-backend/src/user-environment/user-environments.resolver.ts
@@ -167,15 +167,8 @@ export class UserEnvironmentsResolver {
resolve: (value) => value,
})
@UseGuards(GqlAuthGuard)
- userEnvironmentUpdated(
- @Args({
- name: 'id',
- description: 'Environment id',
- type: () => ID,
- })
- id: string,
- ) {
- return this.pubsub.asyncIterator(`user_environment/${id}/updated`);
+ userEnvironmentUpdated(@GqlUser() user: User) {
+ return this.pubsub.asyncIterator(`user_environment/${user.uid}/updated`);
}
@Subscription(() => UserEnvironment, {
@@ -183,15 +176,8 @@ export class UserEnvironmentsResolver {
resolve: (value) => value,
})
@UseGuards(GqlAuthGuard)
- userEnvironmentDeleted(
- @Args({
- name: 'id',
- description: 'Environment id',
- type: () => ID,
- })
- id: string,
- ) {
- return this.pubsub.asyncIterator(`user_environment/${id}/deleted`);
+ userEnvironmentDeleted(@GqlUser() user: User) {
+ return this.pubsub.asyncIterator(`user_environment/${user.uid}/deleted`);
}
@Subscription(() => Number, {
diff --git a/packages/hoppscotch-backend/src/user-environment/user-environments.service.spec.ts b/packages/hoppscotch-backend/src/user-environment/user-environments.service.spec.ts
index 849b589e1..5eff98e0e 100644
--- a/packages/hoppscotch-backend/src/user-environment/user-environments.service.spec.ts
+++ b/packages/hoppscotch-backend/src/user-environment/user-environments.service.spec.ts
@@ -369,7 +369,7 @@ describe('UserEnvironmentsService', () => {
);
return expect(mockPubSub.publish).toHaveBeenCalledWith(
- `user_environment/${result.id}/updated`,
+ `user_environment/${result.userUid}/updated`,
result,
);
});
@@ -398,7 +398,7 @@ describe('UserEnvironmentsService', () => {
);
return expect(mockPubSub.publish).toHaveBeenCalledWith(
- `user_environment/${result.id}/updated`,
+ `user_environment/${result.userUid}/updated`,
result,
);
});
@@ -463,7 +463,7 @@ describe('UserEnvironmentsService', () => {
await userEnvironmentsService.deleteUserEnvironment('abc123', 'env1');
return expect(mockPubSub.publish).toHaveBeenCalledWith(
- `user_environment/${result.id}/deleted`,
+ `user_environment/${result.userUid}/deleted`,
result,
);
});
@@ -557,7 +557,7 @@ describe('UserEnvironmentsService', () => {
await userEnvironmentsService.clearGlobalEnvironments('abc123', 'env1');
return expect(mockPubSub.publish).toHaveBeenCalledWith(
- `user_environment/${result.id}/updated`,
+ `user_environment/${result.userUid}/updated`,
result,
);
});
diff --git a/packages/hoppscotch-backend/src/user-environment/user-environments.service.ts b/packages/hoppscotch-backend/src/user-environment/user-environments.service.ts
index 9daa9cb46..7754209bb 100644
--- a/packages/hoppscotch-backend/src/user-environment/user-environments.service.ts
+++ b/packages/hoppscotch-backend/src/user-environment/user-environments.service.ts
@@ -151,7 +151,7 @@ export class UserEnvironmentsService {
};
// Publish subscription for environment update
await this.pubsub.publish(
- `user_environment/${updatedUserEnvironment.id}/updated`,
+ `user_environment/${updatedUserEnvironment.userUid}/updated`,
updatedUserEnvironment,
);
return E.right(updatedUserEnvironment);
@@ -192,7 +192,7 @@ export class UserEnvironmentsService {
// Publish subscription for environment deletion
await this.pubsub.publish(
- `user_environment/${deletedUserEnvironment.id}/deleted`,
+ `user_environment/${deletedUserEnvironment.userUid}/deleted`,
deletedUserEnvironment,
);
return E.right(true);
@@ -253,7 +253,7 @@ export class UserEnvironmentsService {
// Publish subscription for environment update
await this.pubsub.publish(
- `user_environment/${updatedUserEnvironment.id}/updated`,
+ `user_environment/${updatedUserEnvironment.userUid}/updated`,
updatedUserEnvironment,
);
return E.right(updatedUserEnvironment);