From ae5481026b30f50a045503271c1791a3d271a9cb Mon Sep 17 00:00:00 2001 From: Convly Date: Thu, 16 Mar 2023 14:30:07 +0100 Subject: [PATCH] Fix broken populate traversal with no fragment --- packages/core/utils/lib/traverse/query-populate.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/utils/lib/traverse/query-populate.js b/packages/core/utils/lib/traverse/query-populate.js index 89ddbbe11b..b836e3383a 100644 --- a/packages/core/utils/lib/traverse/query-populate.js +++ b/packages/core/utils/lib/traverse/query-populate.js @@ -160,6 +160,8 @@ const populate = traverseFactory() const { components } = attribute; const { on, ...properties } = value; + const newValue = {}; + // Handle legacy DZ params let newProperties = properties; @@ -168,11 +170,15 @@ const populate = traverseFactory() newProperties = await recurse(visitor, { schema: componentSchema, path }, newProperties); } - // Handle new morph fragment syntax - const newOn = await recurse(visitor, { schema, path }, { on }); + Object.assign(newValue, newProperties); - // Recompose both syntaxes - const newValue = { ...newOn, ...newProperties }; + // Handle new morph fragment syntax + if (on) { + const newOn = await recurse(visitor, { schema, path }, { on }); + + // Recompose both syntaxes + Object.assign(newValue, newOn); + } set(key, newValue); } else {