undeadlol1
Are There Any Ash Framework Starter or Boilerplate Projects?
This question was inspired by this thread: Open Source Projects Using Ash Framework as Learning Resources.
The Ash framework is amazing, but as a newcomer to Elixir, getting started with it can be quite challenging. To build a real application, you need to understand at least five different Ash libraries—such as ash_phoenix, ash_auth, ash_policies, ash_postgres, ash_rbac, and ash_json_api/ash_graphql—along with Phoenix and Phoenix LiveView. While learning these technologies is certainly possible, and the learning curve isn’t the steepest, integrating them all into a working application can be incredibly difficult.
Moreover, different people have different learning styles. Personally, when learning a new technology, I often search for something like a “React boilerplate project” and start hacking away. By the end of the process, not only do I learn the new technology, but I also have something practical to show for it. Unfortunately, I haven’t been able to do the same with Ash—I just get overwhelmed by the number of required libraries.
Another reason why boilerplate projects are valuable is that no one likes reinventing the wheel. While building everything from scratch can be a great learning experience, it becomes tedious when it’s not your first time around.
Note: The closest things to a starter project I could find are these repositories:
Marked As Solved
zachdaniel
I think that we do emphasize igniter pretty well in the book, using it to install the various components we might need etc. i.e mix igniter.install ash_authentication, mix igniter.install ash_authentication_phoenix and mix ash_authentication.add_strategy.
Igniter & Ash are intended to bring us to a different point than the concept of your standard boilerplate, where you don’t have to opt into the kitchen sink of someone else’s application, you can just install the things you need when you need them.
So if I started out with an application with some example resources:
mix igniter.new my_app --with phx.new --install ash --example
Now if you want authentication in your app, you just say
mix igniter.install ash_authentication_phoenix --auth-strategy magic_link
(these examples are real, you can run them)
And if you realized that you wanted password authentication too, you don’t have to go back to a boilerplate and copy/paste or something, you just mix ash_authentication.add_strategy password.
Honestly there is still a lot more work to do on this front, but I think we’re moving in the right direction.
Some major pieces left:
-
I’d like to do is to make the
--exampleflag do things in other extensions as well. Currently onlyashreacts to it to create some example resources. -
Another thing is to make the
mix ash.extendcommand do more than it currently does, for example:mix ash.extend MyApp.Helpdesk.Ticket graphqlwill add theAshGraphqlextension to a resource, but does not configure any mutations and queries etc. -
mix ash.gen.resource MyApp.MyResourceshould merge things into the resource in question instead of just ignoring if the resource already exists.
Also Liked
undeadlol1
I’m not sure where else to post this, so I’m writing it here.
Thank you for writing (or co-authoring) the Ash Framework book. As I mentioned in my original post, I struggled for weeks trying to wrap my head around Ash and its associated libraries—it was an on-and-off process of trying and failing. But after reading the book, I can finally say that I truly understand Ash and I feel confident writing my own code with it. Thank you for making this possible.
I know that the official documentation and guides took a lot of effort to create, and I don’t want to diminish that. However, without the book, I was really struggling. Your work has made a significant difference in my learning journey.
sevenseacat
Awesome! That’s exactly what we were hoping the book would do for people
I’m so glad to hear it!
zachdaniel
That’s a cool idea
mix ash.gen.calculation Name.Of.Calc --resource MyApp.Foo.Bar could also add it to the resource module. I think you might be surprised at just how actually doable that is.
For an adventurous soul:
mix igniter.gen.task ash.gen.calculation- update the docs of the task
- modify the positional and schema keys to have the described options
- use
Igniter.Project.Module.create_moduleto create the module - go to
Ash.Resource.Igniterand copy theadd_new_attributelogic into aadd_new_calculationfunction and adjust it accordingly - call that new function from the igniter task if the resource flag is set.
Alternatively, there are plans to make mix ash.gen.resource merge into existing resources, so we could add --calculation foo:type:Module to that task, and if the module doesn’t exist it is created as a shell (by delegating to mix ash.gen.calculation) meaning that the calculation gen task doesn’t know about resources it just creates the shell of a calculation.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









