Describe the bug
PR #4118 (v3.5.3) activated a previously dead-code filter in OrderService.findByCustomerId that silently strips any relation path containing productVariant:
const effectiveRelations = (relations ?? defaults).filter(
r => !r.includes('productVariant'),
);
This silently discards explicitly requested relations with no warning, breaking service-layer code and degrading GraphQL performance.
Honestly it just seems like weird behavior for the server function. Additionally, I've not seen anywhere that explains what the filter is for, as previous issues linked as relevant were marked as fixed by different code, and since it hasn't been used in a long time, are we sure it actually fixes anything?
To Reproduce
Steps to reproduce the behavior:
- Call orderService.findByCustomerId(ctx, customerId, options, ['lines', 'lines.productVariant', 'lines.productVariant.product'])
- Access order.lines[0].productVariant on the returned orders
- It is undefined despite being explicitly requested
Expected behavior
Explicitly passed relation paths should be loaded on the returned entities, or the method should throw/warn if it cannot honor them. Prior to v3.5.3, the passed relations were used directly and productVariant was loaded as requested.
Actual behavior
Two issues:
- Service-layer callers get silently broken results. Any code that calls findByCustomerId with productVariant relations and then accesses them on the returned entities will find them undefined. There is no warning or error — the relations are silently stripped. Code that worked in v3.5.2 now silently returns wrong results (e.g. counts that are always 0, missing data in business logic).
- GraphQL queries through Customer.orders get N+1 degradation. The CustomerEntityResolver.orders field resolver uses findByCustomerId. When a query requests productVariant fields on order lines, the eager-loaded join is stripped and each productVariant is instead resolved individually by the OrderLineEntityResolver.productVariant field resolver. Before this change, customer { orders { items { lines { productVariant { name } } } } } loaded everything in a single joined query. Now it issues a separate query per order line.
Environment (please complete the following information):
- @vendure/core version: 3.5.5
- Nodejs version: 22
- Database: postgres
- Operating System: linux
- Package manager: yarn v4
Workaround
Bypass findByCustomerId and query directly via TransactionalConnection / query builder, or use EntityHydrator to load the relations after the fact.
Additional context
Describe the bug
PR #4118 (v3.5.3) activated a previously dead-code filter in OrderService.findByCustomerId that silently strips any relation path containing productVariant:
This silently discards explicitly requested relations with no warning, breaking service-layer code and degrading GraphQL performance.
Honestly it just seems like weird behavior for the server function. Additionally, I've not seen anywhere that explains what the filter is for, as previous issues linked as relevant were marked as fixed by different code, and since it hasn't been used in a long time, are we sure it actually fixes anything?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Explicitly passed relation paths should be loaded on the returned entities, or the method should throw/warn if it cannot honor them. Prior to v3.5.3, the passed relations were used directly and productVariant was loaded as requested.
Actual behavior
Two issues:
Environment (please complete the following information):
Workaround
Bypass findByCustomerId and query directly via TransactionalConnection / query builder, or use EntityHydrator to load the relations after the fact.
Additional context