{@thread.name}

kernel_io
2023-06-06

kernel_io:

I’ve just started playing with Ash.Flow and I’ve got a few questions.

  1. Is it possible to have a branch step with a condition like expr(Money.positive(^arg(:amount))) , I’ve tried and get a Spark DSL error.
  2. Is there a neater way to get_by a resource (similar to how we do it for code_interface) than having to define a separate action? - or does this go against the ethos of Ash.Flow , currently it seems slightly disjointed, with one part of the API encouraging one way and providing nice helpers, but another part not being really integrated, I’m assuming this is just me wanting to use it wrong and carry over certain bad habits / not knowing the magic helpers that do exist…
  3. Are there plans to have a flow be able to be invoked via a code_interface?
  4. Related to #2, is the input of a read step passed through to the action directly, i.e: can I pass in a load/2 as part of the input template? Or is it encouraged to just have a separate step loading the related data?
  5. if I wanted to calculate some values within a Flow, I assume I’m doing it wrong? I could use a Custom step for that, but that itself seems like using the wrong tool for the job.

kernel_io:

Few Ash.Flow questions

zachdaniel:

1.) no, you need to make a custom step like custom :check_if_positive, &Money.positive(&1.amount), input: %{amount: ^arg(:amount)} and then branch off of the result of that 2.) I think there should be a way to set something like get? in a read step 3.) at some point potentially, but at the moment the new “generic actions” are a good way to go about it. 4.) I don’t recall if we set up support for a load option. You may need a custom step to load after reading and/or to add a PR w/ the load option. What it accepts is action input, i.e arguments/attributes 5.) a custom step is likely the best way to compute values

kernel_io:

A new question, how would you recommend I integrate a Flow with an AshPhoenix.Form? Currently all I can think of is by using a manual update/create action?

zachdaniel:

Yeah that’s pretty much the only way.

zachdaniel:

We’d like to add AshPhoenix.FlowForm some day potentially.