undeadlol1

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:

GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with backend built with Ash Framework · GitHub

GitHub - sevenseacat/tunez at end-of-chapter-8 · GitHub

Marked As Solved

zachdaniel

zachdaniel

Creator of Ash

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 --example flag do things in other extensions as well. Currently only ash reacts to it to create some example resources.

  • Another thing is to make the mix ash.extend command do more than it currently does, for example: mix ash.extend MyApp.Helpdesk.Ticket graphql will add the AshGraphql extension to a resource, but does not configure any mutations and queries etc.

  • mix ash.gen.resource MyApp.MyResource should merge things into the resource in question instead of just ignoring if the resource already exists.

Also Liked

undeadlol1

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

sevenseacat

Author of Ash Framework

Awesome! That’s exactly what we were hoping the book would do for people :heart_eyes: I’m so glad to hear it!

zachdaniel

zachdaniel

Creator of Ash

That’s a cool idea :+1: 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_module to create the module
  • go to Ash.Resource.Igniter and copy the add_new_attribute logic into a add_new_calculation function 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.

Where Next?

Popular in Questions Top

beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call t...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54250 245
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement