Open mschipperheyn opened 2 months ago
Additional information about this issue.
I was actually working with an orderline directly (which for our scenario is necessary) like so, which causes the issue
await entityHydrator.hydrate(ctx, orderLine, {
relations: [
'order',
'customFields.assignedCustomer',
'customFields.preferredGroup',
'productVariant',
],
})
If I add this, the issue doesn't occur
await entityHydrator.hydrate(ctx, orderLine, {
relations: [
'order',
'order.shippingLines',
'order.lines',
'customFields.assignedCustomer',
'customFields.preferredGroup',
'productVariant',
],
})
@michaelbromley if you agree that hydration keys should be merged to avoid this issue at the order service level getOrderOrThrow
method by merging relations instead of replacing them, I can go ahead and write that.
Describe the bug I started running into this issue in our populate script after some heavy refactoring.
The problem is here . The getOrderOrThrow allows a custom
relations
key to be passed in. However, whendiscounts()
is accessed on theOrder
entity, an error will be thrown if thelines
key is not hydrated.It's hard to debug because in my case it's being thrown from an
order-confirmation
email that gets triggered by my code. To Reproduce Steps to reproduce the behavior:addItemToOrder
with a customrelations
key that doesn't includelines
Expected behavior Order should hydrate the necessary keys it needs to process instead of throwing errors. The relations key on the getOrderOrThrow should merge required keys with incoming keys using a
Array.from(new Set(...relations, ...['lines', etc]))
Environment (please complete the following information):