-
I'm looking at the action data filter and understand how the fromStateData, results, and toStateData are used. I'm seeing some ambiguity on how to handle a specific edge case. From one of the examples, the results are filtering elements from the action output and placing it into the
In this case where the value of results is an array of string, what should happen if |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
In the spec, you can read the following regarding the
In other words, the whole action result would be merged back into the stateData, which would then become the array of string, in your example. |
Beta Was this translation helpful? Give feedback.
-
@cdavernas @VicNgu For now what is expected is that user understands the result and can use jq to manipulate it, so for your example if result is "results": "${ {"thingstobuy": [.breads[0], .pasta[1] ] } }", in which case toStateData can still be optional ....jq is pretty magic hehe |
Beta Was this translation helpful? Give feedback.
@cdavernas @VicNgu
It's pretty hard for spec to define this rule correctly since we do not control the result type.
If you have ideas like how to do this, like set unique id of action/event def and use that as a key, or something else, i am all ears.
For now what is expected is that user understands the result and can use jq to manipulate it, so for your example if result is
{
"breads": ["baguette", "brioche", "rye"],
"pasta": [ "penne", "spaghetti", "ravioli"]
}
then you can use jq:
"results": "${ {"thingstobuy": [.breads[0], .pasta[1] ] } }",
in which case toStateData can still be optional
....jq is pretty magic hehe