Преглед на файлове

chore: Fix failing test as a result of merge

Michael Bromley преди 3 години
родител
ревизия
b98220b6ae
променени са 1 файла, в които са добавени 9 реда и са изтрити 16 реда
  1. 9 16
      packages/core/src/service/services/order.service.ts

+ 9 - 16
packages/core/src/service/services/order.service.ts

@@ -301,30 +301,23 @@ export class OrderService {
         options?: ListQueryOptions<Order>,
         relations?: RelationPaths<Order>,
     ): Promise<PaginatedList<Order>> {
+        const effectiveRelations = (
+            relations ?? ['lines', 'lines.items', 'customer', 'channels', 'shippingLines']
+        ).filter(
+            r =>
+                // Don't join productVariant because it messes with the
+                // price calculation in certain edge-case field resolver scenarios
+                !r.includes('productVariant'),
+        );
         return this.listQueryBuilder
             .build(Order, options, {
-                relations: relations ?? [
-                    'lines',
-                    'lines.items',
-                    'customer',
-                    'channels',
-                    'shippingLines',
-                ],
+                relations: relations ?? ['lines', 'lines.items', 'customer', 'channels', 'shippingLines'],
                 channelId: ctx.channelId,
                 ctx,
             })
             .andWhere('order.customer.id = :customerId', { customerId })
             .getManyAndCount()
             .then(([items, totalItems]) => {
-                if (relations?.includes('lines.productVariant')) {
-                    items.forEach(item => {
-                        item.lines.forEach(line => {
-                            line.productVariant = translateDeep(line.productVariant, ctx.languageCode, [
-                                'options',
-                            ]);
-                        });
-                    });
-                }
                 return {
                     items,
                     totalItems,