fix(orchestration): field alias should represent the isList in the result (#5449)

* fix(orchestration): field alias should represent the isList in the result

* push last fix

* Create witty-rocks-heal.md

* Update remote-joiner.ts

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>

---------

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
Adrien de Peretti
2023-10-23 19:21:07 +02:00
committed by GitHub
parent c67d490db3
commit 5c77029cb0
2 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/orchestration": patch
---
fix(orchestration): field alias should represent the isList in the result

View File

@@ -30,6 +30,7 @@ export class RemoteJoiner {
location: string[]
property: string
path: string[]
isList?: boolean
}[] = []
private static filterFields(
@@ -389,13 +390,15 @@ export class RemoteJoiner {
}
if (Array.isArray(currentItems)) {
if (currentItems.length < 2) {
if (currentItems.length < 2 && !alias.isList) {
locationItem[alias.property] = currentItems.shift()
} else {
locationItem[alias.property] = currentItems
}
} else {
locationItem[alias.property] = currentItems
locationItem[alias.property] = alias.isList
? [currentItems]
: currentItems
}
if (parentRemoveItems !== null) {
@@ -596,6 +599,9 @@ export class RemoteJoiner {
location: currentPath,
property: prop,
path: fullPath,
isList: !!serviceConfig.relationships?.find(
(relationship) => relationship.alias === fullPath[0]
)?.isList,
})
const extMapping = expands as unknown[]