fix: added updated and deleted subscription changes (#24)
This commit is contained in:
@@ -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, {
|
||||||
|
|||||||
@@ -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,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user