Browse Source

fix(core): Do not error when removing deleted variant from channel

Michael Bromley 4 years ago
parent
commit
e3e88282c2
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/core/src/service/services/channel.service.ts

+ 5 - 2
packages/core/src/service/services/channel.service.ts

@@ -88,10 +88,13 @@ export class ChannelService {
         entityType: Type<T>,
         entityId: ID,
         channelIds: ID[],
-    ): Promise<T> {
-        const entity = await this.connection.getEntityOrThrow(ctx, entityType, entityId, {
+    ): Promise<T | undefined> {
+        const entity = await this.connection.getRepository(ctx, entityType).findOne(entityId, {
             relations: ['channels'],
         });
+        if (!entity) {
+            return;
+        }
         for (const id of channelIds) {
             entity.channels = entity.channels.filter(c => !idsAreEqual(c.id, id));
         }