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

Calling policy modules "directly"

Is there a way to invoke a policy module on an "ad-hoc" manner, similar to doing Resource.my_calculation? I have this: ``` defmodule MyApp.Ash.Accounts.User.Authorizers.UserIsMemberOfOrganization do...

select fields from nested associations

I have two tables: users and user_profiles, with a one-to-one relationship. I know it might sound a bit silly, but I don't always need the information from the profile. Back to the point: I created a read action for searching that looks like this: ```elixir...

ash sqlite "get your installer" failed

sh <(curl 'https://ash-hq.org/install/mediacontrol?install=phoenix&with_args=--database%20sqlite3') \ && cd mediacontrol && mix igniter.install ash ash_phoenix ash_sqlite ash_authentication \ ash_authentication_phoenix ash_admin live_debugger tidewave --auth-strategy password --yes \ && mix ash.setup ...
Solution:
okay try again

Relationship-Based Policies

I’m building an app with a many-to-many between Users and Teams via a TeamMember join resource and need guidance writing two related authorization policies: 1. TeamMember Resource Policy In team_member.ex I’ve defined: ```elixir read :list_team_members do...
Solution:
You can use relates_to_actor_via

Full text search on a given field in ash expression?

I have a table, which emits the map like %{question_text: "filter keyword that should exist"} I am composing queries like ``` filter_expr = Ash.Expr.expr(contains(^key , ^value))...

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.