Skip to content

Commit

Permalink
fix(core): Add missing Order.customer field resolver
Browse files Browse the repository at this point in the history
Fixes #2715
  • Loading branch information
michaelbromley committed Mar 4, 2024
1 parent 09c66fe commit dad7f98
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/core/src/api/resolvers/entity/order-entity.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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,
) {}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit dad7f98

Please sign in to comment.