function
ReplaceChild
ReplaceChild deliberately replaces one direct child, including its kind, policies, and attachments. Unrelated children and the parent's own policies are preserved. A failed replacement returns the original parent and an error.
Arguments
| Argument | Type | Description |
|---|---|---|
parent | Parent | The parent value. |
name | string | The name value. |
replacement | Node | The replacement value. |
Returns
The declared result.
(Parent, error)Full signature
func ReplaceChild[Parent interface {
Node
EditChildren(func(*ChildrenDraft) error) (Parent, error)
}](parent Parent, name string, replacement Node) (Parent, error)Related types
NodeNode is any field definition that can be placed in Fields. Authors normally create nodes with constructors such as Text, Select, Group, or Array and use their concrete fluent methods before adding them to a field list. The interface is sealed so Ridu can snapshot every supported field safely.
ChildrenDraftChildrenDraft owns a detached slice. Committing snapshots again, so retained drafts cannot mutate published graphs. Structural edits are explicit.