Skip to content

Merging Schemas #872

Answered by cueckoo
cueckoo asked this question in Q&A
Jul 3, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Original reply by @mpvl in cuelang/cue#872 (comment)

Note entirely sure what your flow is, but could you not just call Constrain repeatedly for the same value?

In general CUE, not using cuego, one could use FillPath or Unify for this purpose:

// Filling multiple Go values:

var r cue.Runtime
inst, err := r.Compile("foo", "_")
// ... handle error
v := inst.Value()

root := cue.Path{}

// Merge in Go values
v = v.FillPath(root, value1)
v = v.FillPath(root, value2)

// Merge in CUE values
inst, err = r.Compile("", cueString1)
v = v.Unify(inst.Value()) // can also use FillPath(root, v).

if err := v.Err(); err != nil {
    // handle error
}

Replies: 1 comment 1 reply

Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
1 reply
@cueckoo
Comment options

cueckoo Jul 3, 2021
Collaborator Author

Answer selected by cueckoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant