Skip to content

Commit

Permalink
fix(core): Improve resolution of OrderLine.featuredAsset (#3177)
Browse files Browse the repository at this point in the history
  • Loading branch information
taxilian authored Dec 2, 2024
1 parent adfbda6 commit 4530c81
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ export class OrderLineEntityResolver {
@Ctx() ctx: RequestContext,
@Parent() orderLine: OrderLine,
): Promise<Asset | undefined> {
if (orderLine.featuredAsset !== undefined) {
return orderLine.featuredAsset;
} else {
// In some scenarios (e.g. modifying an order to add a new item), orderLine.featuredAsset is an object
// with only an `id`. Since the resolver expects the featuredAsset to be a full Asset object, we need to
// fetch the full Asset object if it's not already populated.
if (!orderLine.featuredAsset?.preview) {
return this.assetService.getFeaturedAsset(ctx, orderLine);
} else {
return orderLine.featuredAsset;
}
}

Expand Down

0 comments on commit 4530c81

Please sign in to comment.