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

Multitenancy with code interface on the domain?

So I have this: ```elixir defmodule MyApp.FlyingTrainingOrg do use Ash.Domain # ......
Solution:
There is a tenant option to all code interfaces 🙂

:datetime with constraints vs :utc_datetime_usec

Hey all, I’m looking at the docs for the different datetime options and they mention >A wrapper around :datetime for backwards compatibility https://hexdocs.pm/ash/Ash.Type.UtcDatetimeUsec.html...
Solution:
They are equivalent and will likely not change anytime soon. Someday we may warn when you use :utc_datetime_usec over the constraint.

For update form with params?

I'm wondering, when using for_update on an existing resource, do I need to explicitly make a params map? I was expecting it'd be auto populated. Even when I did Map.take/2 on the resource and put that as params it didn't work because params expect string keys. Am I missing something or is this expected? 🤔

after_action is not being triggered

I've tried several combinations, but it seems that the after_action callback is not being triggered. As a basic test, I added an IO.inspect expecting to see output in my IEx session, but nothing gets logged. Here's the code I'm using: ```elixir...

AAP and Phoenix.LiveDashboard

If I put live_dashboard inside my ash_authentication_live_session :admin_required router block, I get a compilation error about nested live sessions.
** (RuntimeError) attempting to define live_session :live_dashboard inside :admin_required.
live_session definitions cannot be nested.
** (RuntimeError) attempting to define live_session :live_dashboard inside :admin_required.
live_session definitions cannot be nested.
...

Unable to send a `Ash.Type.File` as argument to action using `AshPhoenix.Form`

When trying to send a Ash.Type.File struct as an argument to an update action, AshPhoenix.Form is failing on validation. Worth nothing that sending the file argument as :override_params in AshPhoenix.Form.submit does bypass this and work correctly, as does calling the action directly. AshAdmin also exhibits this behaviour. ...

Guidance on Generators

Need to implement a generator for a resource action that makes use of after_action hooks (organization > establishment > establishment_user) This is my chain of actions: ```elixir...

Unable to get authenticated with google, after following google login flows

Even if i'm successfully seeing the google login flow (on google side), i'm being redirected as unauthenticated with this toast error: "Incorect email or password", with no other errors in the console.

is there a way to perform a bulk update but for individual items?

given an input like [{store_id: 1, some_data: 2}, {store_id: 3, some_data: 9}], can I configure bulk_update to update store 1 with some_data 2, etc etc

reactor_req - argument option in dsl is missing

Weird because wait_for does work, which supposedly unsugars to argument :_, result(step_to_wait_for). Error:
Compiling 1 file (.ex)
error: undefined function argument/2 (there is no such import)
│
122 │ argument :agent_result, result(:generate)
Compiling 1 file (.ex)
error: undefined function argument/2 (there is no such import)
│
122 │ argument :agent_result, result(:generate)
...

relationship data

Hello everyone! I'm trying to migrate the backend of an old ember app from rails/json-api-resources to Ash. The resources produced by rails contain relationship data even when not added in includes. I can't reproduce this with Ash, and would like to know if it's possible. ``` {...

many to many relationships management.

I couldnt find clear way but got it working. Eventually i got it working, but i would like to get some tips/tricks, if this they way, or am i missing something obvious? ```elixir Resource actions do...

Tips to speed up compile times?

As my resources have grown, my compile times have gotten irritatingly long. Any tips for improving them?
Solution:
```elixir defmodule Foo do use Ash.Resource.Change def change(changeset, opts, context) do...

Questions about Cinder

This is a really cool library and I've toyed around with it a little bit, but I do have a couple questions I was hoping someone could help out with. Are you able to do queries for the filters? For example, say we have a timestamp expired_at but we want a dropdown select the the options expired or active rather than a datetime range, is that possible? I couldn't quite figure out how to set the filter to say I want one to be the nil values and the other to be not is_nil(expired_at. And with calculations, can we have them as one of the columns? Say we have a full_name calculation that combines first_name and last_name. Can we just do user.full_name or would we need to explicitly load it to get it to work?...

Custom type not showing in Admin UI update form

I have a custom type that wraps %Duration{} with some custom logic for parsing it from a string then converting it back to a string. I've implemented the protocol Phoenix.HTML.Safe which just calls my function to return a string of the duration. My custom duration shows up in the primary read action of the Admin UI. It also shows up when I click the little circled into button on a row....

Union queries that return union types

I want to make a union query that will return a union type, which will be resolved with graphql. Could not find an example, and Combination queries seem to be for a different usecase. Can this be done with declarative syntax or do I need a separate custom query? thank you...
Solution:
combination queries don't support producing different resources

Bypassing multitenancy directly from code interfaces

I know there is the multitenancy :bypass option for read actions but is it possible to pass it as an option in code interfaces as well? Something like this or similar is what I'm looking for: ```elixir...

Ash.page resulting in ** (EXIT) no process: the process is not alive or there's no process currently

My paginated read query is failing with this error. This used to work fine, so I wonder if something changed with Ash. ``` 17:13:23.603 [error] GenServer #PID<0.2666.0> terminating ** (stop) exited in: GenServer.call(#PID<0.2670.0>, {:get_and_update, #Function<0.88285443/1 in Ash.Actions.Read.AsyncLimiter.async_or_inline/4>}, 5000)...

Loading multitenant resources

Given the following action: ```elixir read :list_organizations do prepare build(load: [:establishments]) end...
Solution:
```elixir read :list_organizations do prepare build(load: [:establishments]) multitenancy :bypass_all end...

How do I get `fragment` in scope in a `prepare` block?

I'm wanting to sort a query using a fragment. I found this https://elixirforum.com/t/how-do-i-sort-records-by-random-in-the-resource-action/58774 that looks like it would work. However, I get an error when I try. My code: ``` read :my_action do argument :embedding, :vector, allow_nil?: false ...