|
|
@@ -3,11 +3,9 @@ import { HistoryEntryListOptions, OrderHistoryArgs, SortOrder } from '@vendure/c
|
|
|
|
|
|
import { assertFound, idsAreEqual } from '../../../common/utils';
|
|
|
import { Order } from '../../../entity/order/order.entity';
|
|
|
-import { ProductOptionGroup } from '../../../entity/product-option-group/product-option-group.entity';
|
|
|
-import { TranslatorService } from '../../../service/index';
|
|
|
+import { CustomerService, TranslatorService } from '../../../service/index';
|
|
|
import { HistoryService } from '../../../service/services/history.service';
|
|
|
import { OrderService } from '../../../service/services/order.service';
|
|
|
-import { ShippingMethodService } from '../../../service/services/shipping-method.service';
|
|
|
import { ApiType } from '../../common/get-api-type';
|
|
|
import { RequestContext } from '../../common/request-context';
|
|
|
import { Api } from '../../decorators/api.decorator';
|
|
|
@@ -17,7 +15,7 @@ import { Ctx } from '../../decorators/request-context.decorator';
|
|
|
export class OrderEntityResolver {
|
|
|
constructor(
|
|
|
private orderService: OrderService,
|
|
|
- private shippingMethodService: ShippingMethodService,
|
|
|
+ private customerService: CustomerService,
|
|
|
private historyService: HistoryService,
|
|
|
private translator: TranslatorService,
|
|
|
) {}
|
|
|
@@ -46,6 +44,16 @@ export class OrderEntityResolver {
|
|
|
return this.orderService.getOrderSurcharges(ctx, order.id);
|
|
|
}
|
|
|
|
|
|
+ @ResolveField()
|
|
|
+ async customer(@Ctx() ctx: RequestContext, @Parent() order: Order) {
|
|
|
+ if (order.customer) {
|
|
|
+ return order.customer;
|
|
|
+ }
|
|
|
+ if (order.customerId) {
|
|
|
+ return this.customerService.findOne(ctx, order.customerId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@ResolveField()
|
|
|
async lines(@Ctx() ctx: RequestContext, @Parent() order: Order) {
|
|
|
if (order.lines) {
|