Ash Elixir

AE

Ash Elixir

Join the community to ask questions about Ash Elixir and get answers from other members.

Join

support

showcase

today-i-learned

Manage relationship argument question

I do not see an argument type for changes when providing a list of target IDs and I want manage_relationship to just add/remove relationships between existing resources (many-to-many). I will try map with just id populated, but that seems redundant.

How to read resource without actions

I'm trying to inspect MyApp.Accounts.Token using iex, but I'm getting NoPrimaryAction error. Is it possible to inspect resources without defining read action? Is there a way to convert it to Ecto.Schema, so I can use Ecto.Query? ...

Json Api

Say I have two resources user and profile. relationship being profile belongs to user. when iam returning user resource how can i return it along with the profile as response from get request?. i have a read action that works well and return data as expected via iex. however if i use the same action on json api, i only recieve user data without profile data. can someone guide me?

Association not working. Is 'property' a reserved name?

I am trying to associate one resource with another. This works well for most resources I have. However there's this one resource called 'Property' that I can' get to associate with any other resource. If you see this code after submitting a form: ```form #=> #AshPhoenix.Form<...

graphql

So I have thumbnail images stored as binaries that I want to expose via graphql as base 64 encoded strings. I have set a default read action with prepare build(load: [:thumbnail_raw, :thumbnail]) where thumbnail_raw is the binary field in the db and thumbnail is a calculated field. I also define the load callback in the calculation to ensure :thumbnail_raw is loaded before the encoding happens in the body of the calc - i.e. there are two places where I force :thumbnail_raw to be loaded. The calc works fine everywhere else, but returns nil when access via graphql. I have IO.inspected the records sent to the calculation and the key I have asked to be loaded isn't loaded. Versions are a little behind, but I've checked the commit logs for changes in these areas and can't see anything: ``` {:ash, "~> 2.4.0"},...

Use of managed_relationship not clear

I am trying to create an action that will create a Supplier and populate the 2 belongs_to relationships it has. I have tried a default create action with the id fields populated, but they do not get set. I have tried manage_relationship with both ids as action arguments and with records as arguments.
The most recent attempt: create :new do argument :company, :uuid do...

Polymorphic Embedded Resources?

Is it possible to have embedded resources be one or more structs for example ```defmodule MainResource do...

Identity not creating unique index

I have a resource with an identity: ```elixir attributes do uuid_primary_key :id ...

AshPhoenix form handling

Question about Ash Phoenix forms. When using ecto and assign_form the names in the form are user[active] for the active field of user schema. For AshPhoenix forms with assign(:form, form) the names are form[active] so it does not know the resource type when building the form. Is there another way to deal with this so the forms do have the resource name in the element names, or do I just need to change the js that was using the old names? This also impacts the LiveView tests using the form he...

How to login with a generated Magic Link in Phoenix (ash_authentication ash_phoenix_authentication)

I'm trying to implement the new Magic Link strategy in ash_authentication. I can succesfully send an email with a magic link token, but how do I use that token to then login the user? For example with password reset, the token goes in the url, and that works, I'd imagine you have to do something similar with a magic link, but that route doesn't seem to be available. This is what mix phx.routes returns, where there's no room to put a token. ```elixir auth_path * /auth/user/magic_link/request ExampleWeb.AuthController {:user, :magic_link, :request}...

Prevent action's changes from being run on `AshPhoenix.Form.validate`

Hello, I have an resource A that has a filed let's say capacity , belongs_to relationship to B resource and create action that has a change LoadDefaultFromRelationship . This change basically fetches the capacity from B resource if none was given in the create action params for A. The problem with such approach is that every time we invoke the AshPhoenix.Form.validate it makes a query to the database for this default value. Is there any way to prevent this change being run on AshPhoenix.Form.validate but still apply on create action?...

submit_errors: [id: {"has already been taken", []}],

When a for_create form is submitted, I get this error. Assuming the id it's referring to is "form", I'm not sure why it thinks it has been taken. ``` api: MyApp.Tweets, method: "post",...

Aggregates still not working correctly

I have a few custom aggregates that have a filter on them that don't seem to work anymore. ```elixir BackOffice.Vehicle |> Ash.Query.aggregate(:pending_jobs_today_count, :count, :jobs, filter: expr(status == "pending")) ...

Could not relate to actor, as no actor was found (and :allow_nil? is false

When I submit a form that triggers :create action which contains change relate_actor(:author), I get this error. What causes no actor to be found despite that there is a logged in user? ``` submit_errors: [ author: {"Could not relate to actor, as no actor was found (and :allow_nil? is false)",...

Support for Postgres generated columns

Postgres supports creating columns that are generated when the row is inserted, updated. In my case, I have a property that has its address separated into multiple columns and I want to create a special field that will have the concatenation of all these fields. I was wondering if AshPostgres has support for that feature....

Support GIST indexes in `custom_indexes` code block

Do Ash Postgres supports more complex indexes in custom_indexes? Right now I'm using custom_statements for it: ```elixir...

Self-referencing a Resource

Question: How do I self-reference a Resource? Detail Description: I have a Person table. I want to describe that he is related to another Person(s). I don't need to know relationship type, except that they are related/know each other Technical Description: Person A :has_many Persons(s) ?...

MyApp.Secrets must implement the 'AshAuthentication.Secret` behaviour.

I followed the example here (https://ash-hq.org/docs/guides/ash_authentication/latest/github-quickstart) but ran into this error. It talks about password_reset which I'm not sure where it's coming from. ``` (EXIT from #PID<0.104.0>) an exception was raised: (Spark.Error.DslError) [nil]...

`bulk_create` requiring `upsert_fields` with `upsert?: true`

Small conflict between the docs and usage of bulk_create: Docs: "If not set, the action's upsert_fields is used, and if that is not set, then any fields not being set to defaults are written." https://hexdocs.pm/ash/Ash.Api.html#c:bulk_create/4 ...

AshPhoenix.Form does not implement the Access behaviour

I'm having this problem when I try to use AshPhoenixForms. I have a liveview with this mount function: ```elixir @impl true def mount(_conn, _session, socket) do...
No description