Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
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.tsindex 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.tsindex 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.tsindex 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 updateawait 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 deletionawait 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 updateawait this.pubsub.publish(- `user_environment/${updatedUserEnvironment.id}/updated`,+ `user_environment/${updatedUserEnvironment.userUid}/updated`,updatedUserEnvironment,);return E.right(updatedUserEnvironment);