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

Read Action Prepare does not load aggregate

I have a resource with a count aggregate for a child resource ``` aggregates do count :response_count, :responses end...

Calculation with arguments used in another calculation for sorting

I have a calculation that uses a postgres function to return a json object: ```elixir calculate :total_hours_report, Hsm.Ash.Payroll.TotalHoursReport,...

AshAuthentication: Set return_to from LiveView redirect to login page

As said in the title, where/how do I set the return_to parameter in AshAuthentication? If it's to be in the session, how do I set that in a liveview? Code snippets will be helpful....

Is it possible to pass a map to args instead of a list of attributes in code_interface?

I'd like to pull off something like: ```elixir actions do update :update_stats do...

Nested forms questions

I'm building a nested form with a single resource that can be nested as many times as the user wants. I cannot use manage_relationship/4 in my case so I'm using after_action hooks that don't seem to work with auto?: true. 1. Is there a way to get a behaviour similar to auto?: true? I'm currently specifying the forms option using a function that just generates recursive options for n levels deep and results in ```elixir forms: [...

Is there an example of defining a resource that is an external API that you are querying from?

I'm trying to wrap my head around modeling a resource that is an external API. Should you even do that?

Deleting intermediary table record in a many_to_many relationship

In this example (https://hexdocs.pm/ash/2.6.18/managing-relationships.html) that Post and Tag have a many_to_many relationshp through PostTag, how do I make it so that the deletion of Post also deletes the record in PostTag , but not Tag? In post.ex, I have this action ```...

How do I make an attribute on a resource unique?

I believe Identities are the way to do it https://ash-hq.org/docs/guides/ash/latest/topics/identities But having trouble finding code examples....

Ash Form Questions

Are there any gotchas with AshPhoenix.Form.create_for and child resources inside an inputs_for? I'm getting an unkown error and I'm not sure what's going wrong because the example in the documentation seems to indicate that the child object in a has_many relationship just gets created? ``` resource |> Form.for_create(action, api: api,...

@derive Jason.Encoder

Hi All, I have an embedded Json object in Ash which is consumed by GraphQL. I have configured graphQL to use json instead of json_string like described here => https://hexdocs.pm/ash_graphql/use-json-with-graphql.html But now I get a Jason.Encoder error. In Ecto this can be solved by adding @derive Jason.Encoder in the module. Is there a way in Ash to do this?...

Access parent result using manage_relationship

Is there a way to access the parent result when using manage_relationship/4? I'm currently using a hook to generate related records but I'm wondering if there is a better way.

cannot be explicitlyGetting error when generating migration: "...converted to an Ecto default"

I'm getting this error when trying to generate a migration: ``` 16:56:34.288 [warning] You have specified a default value for a type that cannot be explicitly converted to an Ecto default:...

GraphQL: Disable filter generation for some read actions?

I am wiring up some AshAuthentication actions to a GraphQL API and I've noticed that it generates filter arguments for actions like signIn(email: String!, password: String!) which is nonsensical. I can see the derive_filter? boolean option for the whole resource, but is there a way to do it for a single query or mutation?

The resource `Example.Accounts.User` does not define an attribute named `:unique_email`

I'm following the getting started guide for Ash Authentication (https://ash-hq.org/docs/guides/ash_authentication_phoenix/latest/tutorials/getting-started-with-ash-authentication-phoenix#reset-password) and I'm getting an error that the :unique_email atom isn't defined. It is defined as an identity though and the only departure I've made from the guide is to set the x.x. dependencies (https://ash-hq.org/docs/guides/ash_authentication_phoenix/latest/tutorials/getting-started-with-ash-authenticat...

What is the difference between `mix ecto.create` and `mix ash_postgres.create`.

In my early experiments, they seem to do the same thing, but not sure if I am missing something. Maybe this is mostly for the --apis flag thing? https://ash-hq.org/docs/mix_task/ash_postgres/latest/ash_postgres-create...

Ash Api without Phoenix setup

Hey folks. It's my first try on Ash Framework and I really liked the approach. I'm trying to build a basic REST API without a mix phoenix setup:...

Ideal location for pivots across APIs

Another one of my registries has grown fairly large and I'm considering a split. The registry is highly connected, and has a lot of many_to_many relationships. Beyond a matter of preference, anything to be aware of when deciding which of the split APIs a given join resource should live? Should cross-API joins work regardless as long as the APIs are on the same repo?

Primary key not counting as identity key for magic link auth

I'm trying to add a magic_link with the resource's primary key :id as identity but it doesn't seem to count as an ID unless it's in the identities block. ```elixir strategies do magic_link do...

have the generator return values from a list (unique)

Hi, I would like to use the generator functionality to create resources and I have a attribute with specific codes. I'm looking for a way to pass a generator that returns values from a list but does not return the same value twice in order for the unique constraint to work correctly....

Spark.Dsl.Entity is option explicit or inferred?

I'm trying to figure out if there is a way to determine if an option was explicitly set or inferred. As an example, say I want to write a Transformer that marks every attribute as sensitive unless it has been explicitly set as non-sensitive (not quite my usecase but close). I've found where Entity.build receives that info as opts, and I can get and replace the attribute with the Transformer helpers, but I'm not seeing any way to determine if it was explicitly set in the Transformer. Is...