Ensure predictable config export order of config-defined component trees

Created on 22 May 2025, about 2 months ago

Overview

<p>For the first time, this config schema type now relies on <code>type: sequence. For DX purposes (debugging, config diffing, etc.), it's important that the sequence keys are ordered A) consistently, B) sensibly.

IMHO the most sensible ordering would be:

  1. first by level in the tree, starting with the top of the tree
  2. within a level, in sibling order
  3. when there's multiple slots, by slot machine name order

That could be achieved by generating keys for each sequence item that represent the path to that component instance:

  • Conceptually: root-instance.slot_name.level1-instance.slot_name.level2-instance
  • Concretely: all those instances would be UUIDs — that'd be insanely long very quickly
  • So instead: don't use the UUID of a component instance, but the sibling index within each level, so that'd be 0.foo.1.bar.3 as the key for the (starting at the deepest level) 4th component instance in the bar slot of the second component instance in the foo slot of the first component instance in the root.

If we did that, then all we'd need to do is add orderby: key to config schema, and the config save/export functionality would automatically sort the tree exactly in that sensible ordering!

Before this MR, that didn't matter a great deal. But after this MR, it's trivially possible to run a DB query that either lists the entire tree, or a subtree, and manipulate the ordering with a simple ORDER BY. It's important that the DX for a developer (or site builder) inspecting big component trees in config is not painful.

That's not a blocker for this issue/MR though; but it should be a stable blocker. Let's create a follow-up issue for that.


— https://git.drupalcode.org/project/experience_builder/-/merge_requests/1...

This is that follow-up.

Proposed resolution

User interface changes

šŸ“Œ Task
Status

Active

Version

0.0

Component

Config management

Created by

šŸ‡§šŸ‡ŖBelgium wim leers Ghent šŸ‡§šŸ‡ŖšŸ‡ŖšŸ‡ŗ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024