Splitting resource using AshStateMachine using `Spark.Dsl.Fragment`

What I was hoping to do was be able to split my state_machine block from the rest of the resource using Spark.Dsl.Fragment. Bit of a catch-22 though, because without using the AshStateMachine extension there's notransition_state to use in actions, but with it there's no definition for initial_states. This hasn't been an issue for anything else, because for other extensions like AshGraphql, AshJsonApi, etc. there aren't the same kind of interdependencies and the rest of the stuff doesn't seem to get hung up because it's all in core. Is this a case worth addressing somehow? I can see there being more extensions in future that would, e.g. similarly provide additional changes builtins, but also have their own DSL section large enough to want to split it.
2 Replies
ZachDaniel
ZachDaniel3y ago
You should be able to use the extension in both the fragment and the parent resource ohhh I see what you mean interesting I'm not sure if there is much we can do on that front TBH but there is an easy-ish fix import AshStateMachine.BuiltinChanges will get you the transition_state available in the main resource
\ ឵឵឵
\ ឵឵឵OP3y ago
I actually did this already 😄 Thought it was an interesting edge case, though. Cool if it's something that's challenging to support architecturally.

Did you find this page helpful?