Ash Framework

AF

Ash Framework

The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.

Join

support

showcase

today-i-learned

How to Compute Permissions

What is the recommended way to design a permissions data structure—based on policies—that can serve as the source of truth for conditional UI rendering? (I am using React via Inertia)
Solution:
in Elixir-land we have Ash.can? and code interfaces have can_<name>? generated

Authenticating an SPA via graphql

Anyone have any tips for authenticating an SPA via graphql? I've got basic ash_authentication boilerplate user/token resources setup. I'm wondering if the best way to do this is to wire up my own query/mutation that can set the token as a cookie... kinda trying to keep the elixir side more purely graphql, so my SPA is the main UI interface and I'm not using the ash_authentication_phoenix routes.
Solution:
"Authenticating via GraphQL"

is AshPyro maintained?

I was trying to use pyro_components which in turn uses pyro . Pyro.Overrides modules is not present , hence pyro_components does not compile. This is believed to be implemented via Spark. I don't know the author's handle here. I wanted to take ash_pyro_components for a spin to see what kind of data tables / forms it would create. But stuck in compilation phase....

Flaky Ash Generator

After adding a number of generators to my application's test suite I started noticing that a resource in particular is starting to get flaky. Sometimes it generates valid data but other times it seemingly returns empty data since all validations fail on the resource. The relevent generator code is: ```elixir defmodule Atlas.Generator do # ......
Solution:
I think I solved it for myself. I didn't realize that Generator was supplying lists of empty maps for an argument children which allowed me to generate child entity types at the same time as the parent. Because the maps were empty, they were failing validation. once I started supplying a default value of an empty list, the flakiness seems to have gone away.

'fanning out' pub sub broadcasts?

I'm looking for a clean approach for 'fanning out' pub sub broadcasts based on relationships. For example, if I have: * teams * team_members - team_id, user_id...
Solution:
I don't think there is any great way to do this declaratively right now. You can add a custom notifier that gets each notification (its just a module that implements the notify option) and broadcast it yourself

Error in action when policy is added

I have this action on the DashboardGroup resource: ``` read :get_by_id do get? true argument :id, :uuid, allow_nil?: false...

changes in generic action

Hi this is the jist of what what to do for my specific use case I know it's not possible: but there must be someway to do this by for example: making the changes runs or the action a create etc. I'm stumped right now so any advice welcome : ) action :request_magic_link do...

ash_double_entry different currency

Working with USD and creating transfers from AshPhoenix.Form.submit() works as expected. I added additional accounts with a different currency, EUR, and this fails with:
* ** (ArgumentError) Cannot subtract two monies with different currencies. Received :EUR and :USD.
* ** (ArgumentError) Cannot subtract two monies with different currencies. Received :EUR and :USD.
...

Is there a way to load a nested parent relationship on a resource?

Is there a way to load a nested parent relationship on a resource? Ie. %MyResource{... parent: %MyResource{... parent: %MyResource{......

Any expected issues when upgrading to otp 28?

Is it safe to upgrade to otp 28 with the changes to regexes?

[AshAuthentication] Unable to redefine User.id as a v7 uuid

If you modify user.ex and redefine id as having the type uuid_v7_primary_key You will get the runtime error: ** (EXIT from #PID<0.94.0>) an exception was raised:...
Solution:
fixed in main of AshAuthentication

Not creating v7 uuids for ids

I'm using Ash 3.5 with AshPostgres. I have a Country resource with the following id attribute: ```...
Solution:
```elixir change fn changeset, _context -> if is_nil(Ash.Changeset.get_attribute(changeset, :id)) do Ash.Changeset.force_change_attribute(changeset, :id, Ash.UUID.generate()) # <- this is in your code you sent else...

Error: `key :manual not found in: nil` with create_query using graphql

So I got this simple resource: ```elixir defmodule Zelo.Planner.PlanResult do @moduledoc false...

inputs_for not working when I do manage_relationship in Ash.Changeset.before_action

Hi team, I would like to ask smth about inputs_for, so when I do manage relatioinship this way change manage_relationship(:beds, type: :create) in the action, inputs_for works. But when I put the manage_relationship in before_action, it doesn't work, e.g.: ```...

AshEvents: AshPostgres.DataLayer.Info.repo/1 is undefined

After installing ash_events on a working Ash+Postgres app (by adding {:ash_events, "~> 0.2.0"}), I get this warning when I start it. Application works otherwise but I don't have ash events wired to any resources yet. warning: AshPostgres.DataLayer.Info.repo/1 is undefined (module AshPostgres.DataLayer.Info is not available or is yet to be defined) │ 25 │ pg_repo = AshPostgres.DataLayer.Info.repo(changeset.resource)...
Solution:
I do have ash_postrgres . Closing this until it's a problem. For now it's just a warning.

How can change dir in Igniter.add_task cross platform? (suggestion)

i have no windows to test it, just get the response from claude that can be wrong it says it is not cross platform code for example in windows has problem ```elixir def run_install(igniter) do...
Solution:
So you need to write a mix task that does what you want

Ash-AI MCP and Cursor

My MCP config in Cursor: ``` { "mcpServers": { "tidewave": {...
Solution:
``` "ash_dev": { "command": "npx", "args": ["mcp-remote@0.1.5", "http://localhost:4000/mcp/ash"] }...

ash_double_entry and updating transfers

I see a unit test that is capable of updating a transfer. However I cannot get it to work and see this error. ```elixir...
Solution:
update :update_balance do
change get_and_lock_for_update()
end
update :update_balance do
change get_and_lock_for_update()
end
...

Reusable Ash Resources

I've got a commonly-used Ash resource that I'd like to put in an Elixir package for reuse across Phoenix apps. Is anyone doing this? Can anyone point me towards examples or best practice? This works, but the otp_app is hardcoded: ``` defmodule Packaged.Resource do...
Solution:
that solved it for me. thanks again for the tips.

AshArchival

Dear team, I am currently trying to implement AshArchival. In order to be able to read the archived and none archived value. the documentation says I need to create a separate resource....