|
@@ -2,9 +2,11 @@ import { Parent, ResolveProperty, Resolver } from '@nestjs/graphql';
|
|
|
|
|
|
|
|
import { Translated } from '../../../common/types/locale-types';
|
|
import { Translated } from '../../../common/types/locale-types';
|
|
|
import { Collection } from '../../../entity/collection/collection.entity';
|
|
import { Collection } from '../../../entity/collection/collection.entity';
|
|
|
|
|
+import { ProductOptionGroup } from '../../../entity/product-option-group/product-option-group.entity';
|
|
|
import { ProductVariant } from '../../../entity/product-variant/product-variant.entity';
|
|
import { ProductVariant } from '../../../entity/product-variant/product-variant.entity';
|
|
|
import { Product } from '../../../entity/product/product.entity';
|
|
import { Product } from '../../../entity/product/product.entity';
|
|
|
import { CollectionService } from '../../../service/services/collection.service';
|
|
import { CollectionService } from '../../../service/services/collection.service';
|
|
|
|
|
+import { ProductOptionGroupService } from '../../../service/services/product-option-group.service';
|
|
|
import { ProductVariantService } from '../../../service/services/product-variant.service';
|
|
import { ProductVariantService } from '../../../service/services/product-variant.service';
|
|
|
import { ApiType } from '../../common/get-api-type';
|
|
import { ApiType } from '../../common/get-api-type';
|
|
|
import { RequestContext } from '../../common/request-context';
|
|
import { RequestContext } from '../../common/request-context';
|
|
@@ -16,6 +18,7 @@ export class ProductEntityResolver {
|
|
|
constructor(
|
|
constructor(
|
|
|
private productVariantService: ProductVariantService,
|
|
private productVariantService: ProductVariantService,
|
|
|
private collectionService: CollectionService,
|
|
private collectionService: CollectionService,
|
|
|
|
|
+ private productOptionGroupService: ProductOptionGroupService,
|
|
|
) {}
|
|
) {}
|
|
|
|
|
|
|
|
@ResolveProperty()
|
|
@ResolveProperty()
|
|
@@ -36,4 +39,12 @@ export class ProductEntityResolver {
|
|
|
): Promise<Array<Translated<Collection>>> {
|
|
): Promise<Array<Translated<Collection>>> {
|
|
|
return this.collectionService.getCollectionsByProductId(ctx, product.id, apiType === 'shop');
|
|
return this.collectionService.getCollectionsByProductId(ctx, product.id, apiType === 'shop');
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @ResolveProperty()
|
|
|
|
|
+ async optionGroups(
|
|
|
|
|
+ @Ctx() ctx: RequestContext,
|
|
|
|
|
+ @Parent() product: Product,
|
|
|
|
|
+ ): Promise<Array<Translated<ProductOptionGroup>>> {
|
|
|
|
|
+ return this.productOptionGroupService.getOptionGroupsByProductId(ctx, product.id);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|