Inject State
name
Unique State name. Must follow the Serverless Workflow Naming Convention
string
yes
type
State type
string
yes
data
JSON object which can be set as state's data input and can be manipulated via filter
object
yes
stateDataFilter
State data filter
object
no
transition
Next transition of the workflow after injection has completed
string or object
yes (if end
is not defined)
compensatedBy
Unique name of a workflow state which is responsible for compensation of this state
string
no
usedForCompensation
If true
, this state is used to compensate another state. Default is false
boolean
no
metadata
Metadata information
object
no
end
Is this state an end state
boolean or object
yes (if transition
is not defined)
Inject state can be used to inject static data into state data input. Inject state does not perform any actions. It is very useful for debugging, for example, as you can test/simulate workflow execution with pre-set data that would typically be dynamic in nature (e.g., function calls, events).
The inject state data
property allows you to statically define a JSON object which gets added to the states data input. You can use the filter property to control the states data output to the transition state.
Here is a typical example of how to use the inject state to add static data into its states data input, which then is passed as data output to the transition state:
The data output of the "SimpleInjectState" which then is passed as input to the transition state would be:
If the inject state already receives a data input from the previous transition state, the inject data should be merged with its data input.
You can also use the filter property to filter the state data after data is injected. Let's say we have:
In which case the states data output would include only people whose age is less than 40:
You can change your output path easily during testing, for example change the expression to:
This allows you to test if your workflow behaves properly for cases when there are people whose age is greater or equal 40.
Note that transition
and end
properties are mutually exclusive, meaning that you cannot define both of them at the same time.
Last updated