|
|
@@ -1,13 +1,17 @@
|
|
|
import { Parent, ResolveField, Resolver } from '@nestjs/graphql';
|
|
|
|
|
|
-import { Asset, OrderLine, ProductVariant } from '../../../entity';
|
|
|
-import { AssetService, ProductVariantService } from '../../../service';
|
|
|
+import { Asset, Order, OrderLine, ProductVariant } from '../../../entity';
|
|
|
+import { AssetService, OrderService, ProductVariantService } from '../../../service';
|
|
|
import { RequestContext } from '../../common/request-context';
|
|
|
import { Ctx } from '../../decorators/request-context.decorator';
|
|
|
|
|
|
@Resolver('OrderLine')
|
|
|
export class OrderLineEntityResolver {
|
|
|
- constructor(private productVariantService: ProductVariantService, private assetService: AssetService) {}
|
|
|
+ constructor(
|
|
|
+ private productVariantService: ProductVariantService,
|
|
|
+ private assetService: AssetService,
|
|
|
+ private orderService: OrderService,
|
|
|
+ ) {}
|
|
|
|
|
|
@ResolveField()
|
|
|
async productVariant(
|
|
|
@@ -31,4 +35,9 @@ export class OrderLineEntityResolver {
|
|
|
return this.assetService.getFeaturedAsset(ctx, orderLine);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @ResolveField()
|
|
|
+ async order(@Ctx() ctx: RequestContext, @Parent() orderLine: OrderLine): Promise<Order | undefined> {
|
|
|
+ return this.orderService.findOneByOrderLineId(ctx, orderLine.id);
|
|
|
+ }
|
|
|
}
|