From 02fe4d1364ae8f37cc033ac4292996bddda481fd Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Tue, 19 Sep 2023 15:37:17 +0200 Subject: [PATCH] fix(orchestration): ToRemoteJoinerHelper property building (#5130) * fix(orchestration): ToRemoteJoinerHelper property building * update fix --- .../src/__tests__/joiner/helpers.ts | 16 ++++++++-------- packages/orchestration/src/joiner/helpers.ts | 5 ++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/orchestration/src/__tests__/joiner/helpers.ts b/packages/orchestration/src/__tests__/joiner/helpers.ts index 94c78eca8a..2b5a3e037e 100644 --- a/packages/orchestration/src/__tests__/joiner/helpers.ts +++ b/packages/orchestration/src/__tests__/joiner/helpers.ts @@ -49,22 +49,22 @@ describe("toRemoteJoinerQuery", () => { fields: ["id", "title", "handle"], expands: [ { - property: "product.variants", + property: "variants", fields: ["sku"], }, { - property: "product.variants.shipping_profiles", + property: "variants.shipping_profiles", }, { - property: "product.variants.shipping_profiles.profile", + property: "variants.shipping_profiles.profile", fields: ["id", "name"], }, { - property: "product.variants.options", + property: "variants.options", fields: ["value"], }, { - property: "product.options", + property: "options", fields: ["value", "name"], }, ], @@ -106,7 +106,7 @@ describe("toRemoteJoinerQuery", () => { fields: ["id", "title", "handle"], expands: [ { - property: "product.variants", + property: "variants", directives: [ { name: "directiveName", @@ -116,10 +116,10 @@ describe("toRemoteJoinerQuery", () => { fields: ["sku"], }, { - property: "product.variants.shipping_profiles", + property: "variants.shipping_profiles", }, { - property: "product.variants.shipping_profiles.profile", + property: "variants.shipping_profiles.profile", args: [ { name: "context", diff --git a/packages/orchestration/src/joiner/helpers.ts b/packages/orchestration/src/joiner/helpers.ts index e845df8e33..ba8f288d32 100644 --- a/packages/orchestration/src/joiner/helpers.ts +++ b/packages/orchestration/src/joiner/helpers.ts @@ -7,7 +7,7 @@ export function toRemoteJoinerQuery(obj: any): RemoteJoinerQuery { expands: [], } - function extractRecursive(obj, parentName = "") { + function extractRecursive(obj, parentName = "", isEntryPoint = true) { for (const key in obj) { const value = obj[key] @@ -21,7 +21,6 @@ export function toRemoteJoinerQuery(obj: any): RemoteJoinerQuery { property: entityName, } - const isEntryPoint = parentName === "" const reference = isEntryPoint ? remoteJoinerQuery : expandObj if (value.__args) { @@ -47,7 +46,7 @@ export function toRemoteJoinerQuery(obj: any): RemoteJoinerQuery { remoteJoinerQuery.expands!.push(expandObj) } - extractRecursive(value, entityName) + extractRecursive(value, isEntryPoint ? "" : entityName, false) } }