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

AshPhoenix.Form fails to submit with Ash.Error.Query.InvalidFilterValue error

Hey there, I'm not sure exactly what is happenig, but I have a embedded resource that was inserted into my resource, when I try to update it via AshPhoenix, by first calling AshPhoenix.Form.remove_form and then AshPhoenix.Form.submit, I get this error: ```elixir [warning] Unhandled error in form submission for Marketplace.Markets.Property.update ...

AshAuthenticationPhoenix controlling generated routes

I setup my phoenix app using the getting started with ash authentication guide. If I understand correctly adding routes works as follows: ```elixir # Added for macros and functions use AshAuthentication.Phoenix.Router pipeline :browser do...

AshGraphql erroring with key :run not found

I think this is related to the new generic actions changes, but I ran into this after upgrading and pointing to the latest commit of ash_graphql: ``` [error] 0f997ea0-3e42-480e-a425-9d39d18f271f: Exception raised while resolving query. ...

Filter check is returning an error tuple, rather than filtering rows.

I'm trying to use policies to filter out rows whose visibility attribute is not 1. The table contains some rows where visibility == 2, so I expected the query will filter those out. ``` policy action_type(:read) do forbid_if Invisible...

AshPhoenix.Form fails in submit without errors with embedded resources

I have a embedded resource like this: ```elixir defmodule Marketplace.Markets.Property.OffMarket do @moduledoc false...

Issues using Ash.Type.Union

So I'm trying to use Ash.Type.Union and I keep getting errors when attempting to load the resource, I have defined an embedded resource ```elixir defmodule VMX.Transactions.TransactionData.Type.Call do...

Validate not nil, min and max for a string

The following validation code doesn't work: ```elixir attributes do uuid_primary_key :id...

What's the best way to learn Ash?

So i'm trying to learn ash, i don't want to just go through documentation. I want a better way to do it, but couldn't find courses that are up to date. I'm considering making a toy app, but not sure what's something that's beginner friendly and will help me gets the broadest exposure the Ash modules. I have considered making a to-do list, but in reality that'd expose me to maybe 10% of the framework....

Unexpected token during mix ash_phoenix.gen.live

I'm creating a toy application for tracking weight lifting workouts. I have a WeightType resource that I want to create a LiveView for. When running the Ash Phoenix LiveView generator I'm getting the following error and having trouble tracking down where it comes from so I can fix it. Help? `` mix ash_phoenix.gen.live Mitochex.Workouts Mitochex.Workouts.WeightType Would you like to name your actor? For example: current_user`. If you choose no, we will not add any actor logic. [Yn] n...

How To: Return a computed relationship in a read.

I have a resource like Posts. Each Post has a 'top comment'. So when i'm fetching a Post or list of Posts, I will like it to include the top comment like so: post.top_comment. I'm currently trying to use a preparation to load this relationship but not sure how to execute it on the Ash.Query side of things. Any ideas here would be appreciated!...

sort many_to_many

I thought I had asked this question before, but can't seem to find it... It seems like a very common use case, but not sure how to go about this. Is it possible to sort a many_to_many relationship based on a field in the join table....

Resource MyApp.Accounts.FriendLink is not present in any known Ash.Api module.

I'm getting the above warning even though this module is indeed listed in the registry. What am I missing? ``` defmodule MyApp.Accounts.Registry do use Ash.Registry,...

Implementing token inactivity timeout with automatic expiry extend

Hi folks, I am using the ash_authentication password strategy with my resource configured to store all tokens, and require token presence. The project has a VueJS frontend that communicates with the backend via GQL. When a user logs in, the frontend receives the token and includes it in the header as a bearer token. This is all working well. I have set a short-lived token_lifetime, and would now like to add a way to log the user out after a period of inactivity, and also extend their session expiry whenever they make a request to keep them logged in beyond the initial expiry time. I have realised that this may be at odds with using JWTs as the token, as they are effectively tamper proof....

How to: DateTime validation with compare/2

Im trying to compare datetime in an action with compare/2. Code looks like this: ```elixir validate compare(:resumes_at, greater_than: DateTime.utc_now(:microsecond)), message: "resumes_at must be in the future", where: [present(:resumes_at)]...

Using code_interface args

When I use ``` code_interface do define_for Office.ToDoList define :create, args: [:subject]...

ManualRead not resolving in graphQL

Hi All, I have created a ManualRead module to implement a tricky relationship which has defaults that can be overridden. Before going too much into details, this ManualRead is working fine when I use the code interface, but when I call the same action through graphQL the values I expect are all nil. It is a bit too long to paste here, but was wondering if there is something general I need to think of when doing this?...

AshAuthentication missing notifications when running Expunger

I noticed that, for time to time, AshAuthentication Expunger is running and it will generate a warning because of a missing nofitication for removing tokens. Here is one of these warnings with the full stacktrace:...

How to effiently add thousands+ of entries to `many_to_many` relations

I'm having a brain freeze at the moment. I have Controls and Requirements with a many_to_many relation (ControlRequirement). I can set those using manage_relationship... however I now have the use case where I need to add new relations one by one ... thousands of them. My understanding is that manage_relationship with :append_and_remove expects a list ... so I'd need to fetch the list, add an item, remove duplicates and then provide this to manage_relationship, correct? I assume `:ap...

(Postgrex.Error) ERROR 42P18 (indeterminate_datatype) could not determine data type of parameter $1

Gotting the above error while try this code for a regex search. Ash.Query.filter(fragment("task_id ~* '?\\d+'", ^prefix)) The Ecto doc suggests explicitly defining type withtype(^prefix, :string) but I'm not sure how it's supposed to fit in as an Ash.Query. expression....

InvalidFilterValue for read action

I have this relatively simple read action, but it keeps on failing with a %Ash.Error.Query.InvalidFilterValue ```elixir read :for_organisation do argument(:organisation_id, :integer) do...