|
|
@@ -1,10 +1,10 @@
|
|
|
import { Parent, ResolveField, Resolver } from '@nestjs/graphql';
|
|
|
-import { ID } from '@vendure/common/lib/shared-types';
|
|
|
|
|
|
import { Translated } from '../../../common/types/locale-types';
|
|
|
import { Asset } from '../../../entity/asset/asset.entity';
|
|
|
import { Channel } from '../../../entity/channel/channel.entity';
|
|
|
import { Collection } from '../../../entity/collection/collection.entity';
|
|
|
+import { FacetValue } from '../../../entity/facet-value/facet-value.entity';
|
|
|
import { ProductOptionGroup } from '../../../entity/product-option-group/product-option-group.entity';
|
|
|
import { ProductVariant } from '../../../entity/product-variant/product-variant.entity';
|
|
|
import { Product } from '../../../entity/product/product.entity';
|
|
|
@@ -25,6 +25,7 @@ export class ProductEntityResolver {
|
|
|
private collectionService: CollectionService,
|
|
|
private productOptionGroupService: ProductOptionGroupService,
|
|
|
private assetService: AssetService,
|
|
|
+ private productService: ProductService,
|
|
|
) {}
|
|
|
|
|
|
@ResolveField()
|
|
|
@@ -54,6 +55,17 @@ export class ProductEntityResolver {
|
|
|
return this.productOptionGroupService.getOptionGroupsByProductId(ctx, product.id);
|
|
|
}
|
|
|
|
|
|
+ @ResolveField()
|
|
|
+ async facetValues(
|
|
|
+ @Ctx() ctx: RequestContext,
|
|
|
+ @Parent() product: Product,
|
|
|
+ ): Promise<Array<Translated<FacetValue>>> {
|
|
|
+ if (product.facetValues) {
|
|
|
+ return product.facetValues as Array<Translated<FacetValue>>;
|
|
|
+ }
|
|
|
+ return this.productService.getFacetValuesForProduct(ctx, product.id);
|
|
|
+ }
|
|
|
+
|
|
|
@ResolveField()
|
|
|
async featuredAsset(@Ctx() ctx: RequestContext, @Parent() product: Product): Promise<Asset | undefined> {
|
|
|
if (product.featuredAsset) {
|