Kaynağa Gözat

feat(core): Add bulk product deletion mutations

Relates to #853
Michael Bromley 3 yıl önce
ebeveyn
işleme
d5f5490ad1

+ 14 - 0
packages/asset-server-plugin/e2e/graphql/generated-e2e-asset-server-plugin-types.ts

@@ -2406,6 +2406,8 @@ export type Mutation = {
   updateProduct: Product;
   /** Delete a Product */
   deleteProduct: DeletionResponse;
+  /** Delete multiple Products */
+  deleteProducts: Array<DeletionResponse>;
   /** Add an OptionGroup to a Product */
   addOptionGroupToProduct: Product;
   /** Remove an OptionGroup from a Product */
@@ -2416,6 +2418,8 @@ export type Mutation = {
   updateProductVariants: Array<Maybe<ProductVariant>>;
   /** Delete a ProductVariant */
   deleteProductVariant: DeletionResponse;
+  /** Delete multiple ProductVariants */
+  deleteProductVariants: Array<DeletionResponse>;
   /** Assigns all ProductVariants of Product to the specified Channel */
   assignProductsToChannel: Array<Product>;
   /** Removes all ProductVariants of Product from the specified Channel */
@@ -2874,6 +2878,11 @@ export type MutationDeleteProductArgs = {
 };
 
 
+export type MutationDeleteProductsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAddOptionGroupToProductArgs = {
   productId: Scalars['ID'];
   optionGroupId: Scalars['ID'];
@@ -2901,6 +2910,11 @@ export type MutationDeleteProductVariantArgs = {
 };
 
 
+export type MutationDeleteProductVariantsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAssignProductsToChannelArgs = {
   input: AssignProductsToChannelInput;
 };

+ 14 - 0
packages/common/src/generated-types.ts

@@ -2483,6 +2483,8 @@ export type Mutation = {
   updateProduct: Product;
   /** Delete a Product */
   deleteProduct: DeletionResponse;
+  /** Delete multiple Products */
+  deleteProducts: Array<DeletionResponse>;
   /** Add an OptionGroup to a Product */
   addOptionGroupToProduct: Product;
   /** Remove an OptionGroup from a Product */
@@ -2493,6 +2495,8 @@ export type Mutation = {
   updateProductVariants: Array<Maybe<ProductVariant>>;
   /** Delete a ProductVariant */
   deleteProductVariant: DeletionResponse;
+  /** Delete multiple ProductVariants */
+  deleteProductVariants: Array<DeletionResponse>;
   /** Assigns all ProductVariants of Product to the specified Channel */
   assignProductsToChannel: Array<Product>;
   /** Removes all ProductVariants of Product from the specified Channel */
@@ -2951,6 +2955,11 @@ export type MutationDeleteProductArgs = {
 };
 
 
+export type MutationDeleteProductsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAddOptionGroupToProductArgs = {
   productId: Scalars['ID'];
   optionGroupId: Scalars['ID'];
@@ -2978,6 +2987,11 @@ export type MutationDeleteProductVariantArgs = {
 };
 
 
+export type MutationDeleteProductVariantsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAssignProductsToChannelArgs = {
   input: AssignProductsToChannelInput;
 };

+ 14 - 0
packages/core/e2e/graphql/generated-e2e-admin-types.ts

@@ -2406,6 +2406,8 @@ export type Mutation = {
   updateProduct: Product;
   /** Delete a Product */
   deleteProduct: DeletionResponse;
+  /** Delete multiple Products */
+  deleteProducts: Array<DeletionResponse>;
   /** Add an OptionGroup to a Product */
   addOptionGroupToProduct: Product;
   /** Remove an OptionGroup from a Product */
@@ -2416,6 +2418,8 @@ export type Mutation = {
   updateProductVariants: Array<Maybe<ProductVariant>>;
   /** Delete a ProductVariant */
   deleteProductVariant: DeletionResponse;
+  /** Delete multiple ProductVariants */
+  deleteProductVariants: Array<DeletionResponse>;
   /** Assigns all ProductVariants of Product to the specified Channel */
   assignProductsToChannel: Array<Product>;
   /** Removes all ProductVariants of Product from the specified Channel */
@@ -2874,6 +2878,11 @@ export type MutationDeleteProductArgs = {
 };
 
 
+export type MutationDeleteProductsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAddOptionGroupToProductArgs = {
   productId: Scalars['ID'];
   optionGroupId: Scalars['ID'];
@@ -2901,6 +2910,11 @@ export type MutationDeleteProductVariantArgs = {
 };
 
 
+export type MutationDeleteProductVariantsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAssignProductsToChannelArgs = {
   input: AssignProductsToChannelInput;
 };

+ 22 - 0
packages/core/src/api/resolvers/admin/product.resolver.ts

@@ -7,7 +7,9 @@ import {
     MutationCreateProductArgs,
     MutationCreateProductVariantsArgs,
     MutationDeleteProductArgs,
+    MutationDeleteProductsArgs,
     MutationDeleteProductVariantArgs,
+    MutationDeleteProductVariantsArgs,
     MutationRemoveOptionGroupFromProductArgs,
     MutationRemoveProductsFromChannelArgs,
     MutationRemoveProductVariantsFromChannelArgs,
@@ -134,6 +136,16 @@ export class ProductResolver {
         return this.productService.softDelete(ctx, args.id);
     }
 
+    @Transaction()
+    @Mutation()
+    @Allow(Permission.DeleteCatalog, Permission.DeleteProduct)
+    async deleteProducts(
+        @Ctx() ctx: RequestContext,
+        @Args() args: MutationDeleteProductsArgs,
+    ): Promise<DeletionResponse[]> {
+        return Promise.all(args.ids.map(id => this.productService.softDelete(ctx, id)));
+    }
+
     @Transaction()
     @Mutation()
     @Allow(Permission.UpdateCatalog, Permission.UpdateProduct)
@@ -188,6 +200,16 @@ export class ProductResolver {
         return this.productVariantService.softDelete(ctx, args.id);
     }
 
+    @Transaction()
+    @Mutation()
+    @Allow(Permission.DeleteCatalog, Permission.DeleteProduct)
+    async deleteProductVariants(
+        @Ctx() ctx: RequestContext,
+        @Args() args: MutationDeleteProductVariantsArgs,
+    ): Promise<DeletionResponse[]> {
+        return Promise.all(args.ids.map(id => this.productVariantService.softDelete(ctx, id)));
+    }
+
     @Transaction()
     @Mutation()
     @Allow(Permission.UpdateCatalog, Permission.UpdateProduct)

+ 6 - 0
packages/core/src/api/schema/admin-api/product.api.graphql

@@ -19,6 +19,9 @@ type Mutation {
     "Delete a Product"
     deleteProduct(id: ID!): DeletionResponse!
 
+    "Delete multiple Products"
+    deleteProducts(ids: [ID!]!): [DeletionResponse!]!
+
     "Add an OptionGroup to a Product"
     addOptionGroupToProduct(productId: ID!, optionGroupId: ID!): Product!
 
@@ -34,6 +37,9 @@ type Mutation {
     "Delete a ProductVariant"
     deleteProductVariant(id: ID!): DeletionResponse!
 
+    "Delete multiple ProductVariants"
+    deleteProductVariants(ids: [ID!]!): [DeletionResponse!]!
+
     "Assigns all ProductVariants of Product to the specified Channel"
     assignProductsToChannel(input: AssignProductsToChannelInput!): [Product!]!
 

+ 14 - 0
packages/elasticsearch-plugin/e2e/graphql/generated-e2e-elasticsearch-plugin-types.ts

@@ -2406,6 +2406,8 @@ export type Mutation = {
   updateProduct: Product;
   /** Delete a Product */
   deleteProduct: DeletionResponse;
+  /** Delete multiple Products */
+  deleteProducts: Array<DeletionResponse>;
   /** Add an OptionGroup to a Product */
   addOptionGroupToProduct: Product;
   /** Remove an OptionGroup from a Product */
@@ -2416,6 +2418,8 @@ export type Mutation = {
   updateProductVariants: Array<Maybe<ProductVariant>>;
   /** Delete a ProductVariant */
   deleteProductVariant: DeletionResponse;
+  /** Delete multiple ProductVariants */
+  deleteProductVariants: Array<DeletionResponse>;
   /** Assigns all ProductVariants of Product to the specified Channel */
   assignProductsToChannel: Array<Product>;
   /** Removes all ProductVariants of Product from the specified Channel */
@@ -2874,6 +2878,11 @@ export type MutationDeleteProductArgs = {
 };
 
 
+export type MutationDeleteProductsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAddOptionGroupToProductArgs = {
   productId: Scalars['ID'];
   optionGroupId: Scalars['ID'];
@@ -2901,6 +2910,11 @@ export type MutationDeleteProductVariantArgs = {
 };
 
 
+export type MutationDeleteProductVariantsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAssignProductsToChannelArgs = {
   input: AssignProductsToChannelInput;
 };

+ 14 - 0
packages/payments-plugin/e2e/graphql/generated-admin-types.ts

@@ -2406,6 +2406,8 @@ export type Mutation = {
   updateProduct: Product;
   /** Delete a Product */
   deleteProduct: DeletionResponse;
+  /** Delete multiple Products */
+  deleteProducts: Array<DeletionResponse>;
   /** Add an OptionGroup to a Product */
   addOptionGroupToProduct: Product;
   /** Remove an OptionGroup from a Product */
@@ -2416,6 +2418,8 @@ export type Mutation = {
   updateProductVariants: Array<Maybe<ProductVariant>>;
   /** Delete a ProductVariant */
   deleteProductVariant: DeletionResponse;
+  /** Delete multiple ProductVariants */
+  deleteProductVariants: Array<DeletionResponse>;
   /** Assigns all ProductVariants of Product to the specified Channel */
   assignProductsToChannel: Array<Product>;
   /** Removes all ProductVariants of Product from the specified Channel */
@@ -2874,6 +2878,11 @@ export type MutationDeleteProductArgs = {
 };
 
 
+export type MutationDeleteProductsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAddOptionGroupToProductArgs = {
   productId: Scalars['ID'];
   optionGroupId: Scalars['ID'];
@@ -2901,6 +2910,11 @@ export type MutationDeleteProductVariantArgs = {
 };
 
 
+export type MutationDeleteProductVariantsArgs = {
+  ids: Array<Scalars['ID']>;
+};
+
+
 export type MutationAssignProductsToChannelArgs = {
   input: AssignProductsToChannelInput;
 };

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
schema-admin.json


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor