Skip to content

Commit

Permalink
Fix broken populate traversal with no fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
Convly committed Mar 16, 2023
1 parent a9d1afd commit ae54810
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/core/utils/lib/traverse/query-populate.js
Expand Up @@ -160,6 +160,8 @@ const populate = traverseFactory()
const { components } = attribute;
const { on, ...properties } = value;

const newValue = {};

// Handle legacy DZ params
let newProperties = properties;

Expand All @@ -168,11 +170,15 @@ const populate = traverseFactory()
newProperties = await recurse(visitor, { schema: componentSchema, path }, newProperties);
}

Object.assign(newValue, newProperties);

// Handle new morph fragment syntax
const newOn = await recurse(visitor, { schema, path }, { on });
if (on) {
const newOn = await recurse(visitor, { schema, path }, { on });

// Recompose both syntaxes
const newValue = { ...newOn, ...newProperties };
// Recompose both syntaxes
Object.assign(newValue, newOn);
}

set(key, newValue);
} else {
Expand Down

0 comments on commit ae54810

Please sign in to comment.