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 use date_range filter in Cinder.Table

Hey @Rebecca Le first of all, great work with this project. Our custom hacky data table with pagination broke with some deps.update and i added this so quickly without any effort 🙌 Now i am trying to use the date time range filter but when picking any date it raises ```elixir ** (Protocol.UndefinedError) protocol String.Chars not implemented for type Ash.Query (a struct)...
Solution:
can you try main again? have just pushed another fix (and include_time should work properly now as well)

Ash ai prompt wrapper

Moving the question here from the ash development channel: Boris - BackedBy — 08:13 Every time I submit an LLM request, I also submit evaluation criteria. After receiving the main response, I have a validation model respond with 'true' or 'false' re whether the response fits the evaluation criteria. The logprob of the 'true' token is then used as a numerical score for how well the LLM responded. What would be the best approach for extending the ash ai prompt-backed action to have optional criteria: [list of strings] and validation_model: string definitions to run the validation step? Zach Daniel — 08:15 As it stands right now, your best bet would likely be to create a "wrapper" around the prompt action implementation ...

AshGraphQL cannot return null on non nullable field

I have a belongs_to allow_nil? false relationship, and when I use psql I see that the field exists, and the related table contains the data. However when I use graphql to access it I get Cannot return null for non-nullable field
Solution:
do you have permission to read the related record?

"Right" way to do conditional forms

Hello, first of all, thanks for all the work with Ash, it's being incredible and I'm very happy to using it. It's really awesome. I'm facing a challenge here, and just have some questions if maybe there is a way that AshPhoenix forms can help me here. I have a very complex form, where several inputs change based on the selection of some attributes. ...
Solution:
I think you'll essentially need to clean up the UI and/or model your input to the action as a union, and use the union form guides.

Is this possible to encode as a policy?

``` bypass action(:my_action) do authorize_if expr(
^context(:organization_id) == ^tenant() and ^context(:some_key) == ^arg(:some_other_key)...

Runtime values in Filter

I'm trying to achieve the following ecto query in filters ``` def inserted_today(query, user) do query...

"The CLDR provider module Cldr.XYZ.Backend was not found"

Running the "install now script" from the web home page leads to a project with this error. In particular, I executed: ``` mix archive.install hex igniter_new --force...
Solution:
Alright, done!

Using config values in filter expressions

I have a fairly simple read action, like so: ```elixir read :get_by_id do get? true...

Should reusing a used magic link redirect to the sign in screen?

Currently working on tunez and have just added magic_link auth. I at the portion where I am testing out reusing an old magic link for section Debugging when authentication goes wrong and noticed it doesn't redirect back to home or the sign-in and no error toast is shown, is this expected behaviour? (sorry for 480p video, but had to make it under 10MB to post)

Testing with AshAuthentication after upgrade

After upgrading ash_authentication_phoenix and ash_authentication to 2.10.0 and 2.9.2, this test helper function raises an error. ``elixir @doc """ Logs in a user with AshAuthentication` as the current user. """...
Solution:
🤔 You could generate a token and put it into __metadata__

Is there anyway to return a changeset from validation module?

I have a not-simple validation using pure Ecto in Phoenix project. And I want to port over to the project that is using Ash. With Ecto. we used to add errors to changeset in each function `def validate_something(changeset, some) do changeset...

Trickle down multitenancy :bypass

I have an entry point for a resource that bypasses the tenancy ``` read :get_public_event do get_by :id multitenancy :bypass...

Is there a way to detect running in "seed data" mode?

I added a custom GenServer that doesn't need to start when installing seed data using: mix run priv/repo/seeds.exs How might an Ash application know that it was invoked in a utility mode and not completely start itself?...
Solution:
Its not an Ash specific thing though

AshGraphql unknown error

``` Unknown Error * ** (UndefinedFunctionError) function :ok.resource/0 is undefined (module :ok is not available) :ok.resource()...
Solution:
You can create in a before_action hook and use that to update the record

Optimistic updates / syncing with AshEvents

hello! I am prototyping a new project using Ash, AshEvents, and AshStateMachine. It fulfills all of the requirements, save a big one: we need our application to support mutations when the client is offline, with eventual consistency. this leads to two problems: - is there any way to export / separately compile ash resource definitions in some way to be run on a client for optimistic edits, without duplicating the transitions / actions? - when a client returns online, is there a way to retroactively add events to the event log and then replay them? i.e. if an online client performs action A, then the offline client performs B, then the online client performs C, we'd like to generate the resource state in the order of A -> B -> C rather than A -> C -> B once the client syncs. It's not entirely clear from the documentation what happens during replay if the event log now contains events where applying them causes errors, such as illegal state transitions....

Ash Authentication `no case clause matching: "TOKEN_SIGNING_SECRET"`

When installing ash authentication hitting the following error:
mix igniter.install ash_authentication
mix igniter.install ash_authentication
``` Updating project's igniter dependency ✔ checking for igniter in project ✔...

Ash Oban trigger after action

@Rebecca Le continuing from ash oban channel; getting back to this, I have ``` update :my_action do set_attribute(:about_me, "Test")...

session_identifier compilation on AshAuthentication update

When updating AshAuthenticationPhoenix for the security advisory, I also updated AshAuthentication, and that also produces a compile-time error, which is not mentioned in the advisory. ``console ** (Spark.Error.DslError) authentication -> session_identifier: Must set authentication.session_identifier to either :jti or :unsafe`. ...
Solution:
the preferred solution would be to turn on require_token_presence_for_authentication? true

Custom payload body for post endpoint

How can create a generic action so that the exposed endpoint would accept the following payload: ``` { "event": "event", "data": {....}...
Solution:
But yeah TBH for webhooks I typically just write controllers