Ash Weekly: Issue #12
An AlchemyConf retrospective, more generators, new code interface options, more info about enums, and composable sorting.
Ash Weekly!
This is a super quick, informal update about the goings on in and around Ash Framework each week. If you find something interesting and think it should make it on this newsletter, drop a message in the #ash-weekly channel in our Discord server.
Shameless Plugs
Check out Ash Premium Support from Alembic.
Sponsor me if you like what I do.
AlchemyConf Retro
AlchemyConf was just an absolute blast. The folks at Subvisual gave us such a treat, a very memorable conference and absolutely amazing hospitality. I got to meet some truly amazing people. The amount of passion, intelligence and fun that you can find in Elixirists never ceases to amaze me. Loved chatting with all of you, despite the jet lag being pretty rough this time around 😂. Some talk highlights from me in no particular order:
Andrea Leopardi - gen_statem — OTP's Unsung Hero - The feeling that is “all of OTP” in our back pocket is something that is truly a unique feeling for BEAM language developers. We have such a rich vein to tap into, but if we don’t know what’s there, we won’t know when to use it. Talks like these make my batman utility belt that much cooler. One major thing that I appreciated as well is that there are many cases where I don’t want state machines tied to a process (i.e you often will want a data-backed state machine a-la ash_state_machine), but there are a lot of learnings from the design of gen_statem that can be applied to the general FSM concepts. It also doesn’t hurt that Andrea has a great stage presence, an adorable dog that makes an appearance, and a sense of humor to keep things fun.
Julia Mathias - Building a Smart Helpdesk: Using Elixir for Social Good - Turn.io is doing some great work with Elixir, and Julia did an amazing job showing how they are using unique features of the language. It was at a great zoom level, not too deep that you can’t see the forest for the trees, not so zoomed out that you aren’t really talking tech anymore. Unrelated to how much I enjoyed the talk, but Julia also had a couple technical issues that she handled like such a pro. Multiple people swapping cables and hardware around her while she had to riff her content off of memory because her slides weren’t showing and the demo couldn’t play. Props 🙌
Wojtek Mach - Library Client/Server Symmetry - One of the things we see a lot from Wojtek IMHO is some excellent open ended thinking that is really valuable for a growing community like ours. Ranging from the absolutely bonkers, to the eminently practical, I’m always learning from his work. This talk made a (gentle) case for an GenHTTP implementation to land in the standard library, and also highlighted some interesting options that we have if we actually go that route. I won’t do it justice in a sentence, so you’ll just have to wait until it’s up on YouTube, but it is definitely worth a watch.
For everyone else I didn’t mention here, I honestly did not see a single bad talk in the bunch. This list is not a quality assessment, and anyone reading this should be sure to binge what everyone’s talks when they drop on YouTube.
Release day was skipped
Conferences are crazy busy times for me, having to hold down the Ash fort while also socializing and typically prepping, delivering or winding down from a talk and/or a training 🥵. So this week I gave myself some leeway. We’ll be back to business as usual next week on that front. With that said, we still have some nice goodies for you 😎
More Generators
One is shipped currently, and a few more will be landing in the next release. Thanks to @ken-kost for the addition of generators for a bunch of the behavior modules that we use for plugging in custom logic to Ash! This work was originally inspired by a user who had a bug that wouldn’t have happened if we had given them a better way to create a change in the first place.
Code interface custom inputs
We use code interfaces all the time, but it’s important that they are able to support a rich, conventional interface, while allowing our actions to remain simple, or even change over time. `custom_input` is a newly added tool that allows us to solve both of those needs with respect to the positional/optional arguments to our code interface functions. They allow us to add new inputs, or override the inputs that an action takes, and control how those values are mapped to the action input itself. See below for an example, and the guide for more.
More info about enums
This backwards compatible improvement to enums allows configuring labels as well as descriptions for each item. This information will be usable for a bunch of things like codegen tooling (GraphQL schema, OpenAPI spec) and AshPhoenix.Form tooling for things like dropdowns. Thanks Chaz Watkins!
Default sort
Thanks to Abhishek Tripathi for contributing something that folks have wanted for a while! There are often three main separate places that we might specify a `sort`. A relationship might have a `sort`, an action might have a preparation that sorts the underlying data, and the actual *caller* of an action might provide a sort. Those sorts don’t really compose the way that most people want them to, and I’d suggest there isn’t really any “one order to rule them all” if what we’re doing is just smushing them together. The new `default_sort` option gives you more control without having to dip down into preparations and write conditional code. All that `default_sort` means is that “if the query doesn’t have a sort, then add a sort”. But this can be really useful to avoid any of the wacky composability problems mentioned above.
Releases
Ash: 3.5.2
Added `default_sort` for relationships & queries (see above).
Recursively validate options given to subtypes in `Ash.Type.NewType`.
Added `mix ash.gen.change`
Added a custom error explaining that `case` is not valid in expressions, but that you can use `cond`.
Added a helpful error message when an `Ash.Resource.Change` doesn’t implement at least one of the functions we require.
Added `custom_input` to code interface definitions
Added `exclude_inputs` for code interfaces
Added optional description and label values for `Ash.Type.Enum`.
AshPostgres v2.5.14
Create the postgres schema if it doesn’t exist when creating a postgres table for a resource that has a configured schema. Previously we just expected you to have sorted this out yourself, but this is a nice convenience and seems like something it probably should have been doing all along 😂.
🦗🦗🦗🦗🦗🦗🦗
Thank you!