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:
committed by
GitHub
parent
c67d490db3
commit
5c77029cb0
5
.changeset/witty-rocks-heal.md
Normal file
5
.changeset/witty-rocks-heal.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/orchestration": patch
|
||||
---
|
||||
|
||||
fix(orchestration): field alias should represent the isList in the result
|
||||
@@ -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[]
|
||||
|
||||
Reference in New Issue
Block a user