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

Policy engine duplicates/optimizations

To what degree does the policy engine internally prevent reexecution of identical policy checks? Will it evaluate a given MFA only once per request? If so, is there a way to indicate that a policy check is e.g. not dependant on the underlying record?...

Guides or advice for migrating to Ash?

I have a small app with 3 tables in Postgres using Ecto.Table. I am migrating them to use Ash.Resource. When I run mix ash_postgres.generate_migrations for the first time, the generated migrations are to create tables that already exist and the table structures are different. Are there any guides or do you have any advice for reconciling the differences? Original ecto migration:...

Change storage_type of Ash.Type.Term to :binary?

When trying to persist a Term to postgres, I got this error because the term type is string. Changing the storage type/rerunning migrations fixed the issue for me. I can open up a PR if this change seems to make sense to you ** (Postgrex.Error) ERROR 22021 (character_not_in_repertoire) invalid byte sequence for encoding "UTF8": 0x83...

Integrating Google Login via Ash Aunthentication

I’m not sure if this is the right place to ask a question. But I wanted to integrate Google Oauth sign up and login via Ash Authentication. There’s no example of that in the docs, and I’m assuming it works only for email and password. I might be wrong here though 🙈...

Sequence type

Is there a way to get serial or bigserial for an :integer type in AshPostgres?

How to filter associations when preloading them?

I could probably do this with Ecto.Query instead, but I was wondering how I would do it with Ash.Query The scenario, I want to list out all of the Post and I also want to preload the Category association of each post. I also want to filter the categories to only ones that contain a specific category_id....

Casting Binary from Ash.Type.Binary to GraphQL type

Hello, I Have field with type :binary in my resource user which just represents a token generate using :crypto but I get this error Could not determine graphql field type for Ash.Type.Binary any ideas on how to solve this?...

How do I use relationship_display_fields

Could you please explain how to use relationship_display_fields? I couldn't figure it out from the docs or the tweet. Alternatively, is there a way to link the referencing id to the object in the admin panel? eg. if you have a user_id, clicking the user_id takes you to the page for that user...

Proxying actions to other actions

I've found it a useful pattern to do some transformations that then proxy the remainder of the work to another action—often the primary action of its type. The way I'm doing that is roughly: ```elixir actions do...

Reading private attributes stopped working

I recently started not getting back private attributes in my update action. Record looks good via Resource.read, but attribute is nil. Perhaps due to a recent regression or change in semantics?

Ash and AshPhoenix error key needs to be "foreign_resource_id", not "foreign_resource"..

There is a resource "A", and it includes belongs_to :foreign_resource, ForeignResource, and foreign_resource_id column. In phoenix liveview form, after validation I expect error with key "foreign_resource_id" needs to be exist, but only "foreign_resource" error exists. Can I get error with key "foreign_resource_id"?...

Rollback record with Carbonite

I'm trying to achieve the title result. The problem is that trying to set some fields (like foreign keys and timestamps) back to their previous values will mark the changeset as invalid. I'm using force_change_attributes to try to overcome the problem but it is not woking. Is there a way to force the changeset to accept all attributes changes without validating them? Or is there a better way to achieve what I'm trying to achieve?...

Ash Admin seems to be flakey

I'm having a pretty hard time using Ash Admin consistently. The view seems to randomly die and stop accepting updates. In the console I get messages that look like this: phx-F1UJhmZoL62MpQAj error: view crashed - undefined...

Custom validation error not appearing in form

I'm using the .input and .inputs_for components from Phoenix, and I see the normal is required errors in the html when I leave fields blank, but while my custom error shows up in the changeset from IO.inspect I don't see it in the html. The validation: ```elixir defmodule Panacea.Sites.Validations.ValidateHostname do use Ash.Resource.Validation...

Handling file uploads in AshGraphql and AshJsonApi

What's the current/planned support for handling of the :binary type in AshGraphql and AshJsonApi? I've been dealing with binary uploads using a more OOB approach, but would be curious to evaluate other options.

How to determine the cause of a form validation error

I have a couple of resources: ```` defmodule XrtConfiguratorApp.Template.Component do # Using Ash.Resource turns this module into an Ash resource. use Ash.Resource,...

protocol Enumerable not implemented for #Ash.Changeset

I apologize if I abuse the support channel, please tell me if I should take this to #general or #archive-debugging I've ran into this issue on two different resources, and I'll detail both below. The tl;dr is: I define a code_interface for a resource, but when I call the function it fails with protocol Enumerable not implemented for #Ash.Changeset<action_type: :create... at (ash 2.6.27) lib/ash/changeset/changeset.ex:998: Ash.Changeset.cast_params/3 Resource the first...

Ash Philosophy

"Declarative, Introspectable, Derivable" 1. "Introspectable" is related to Ash.Resource.Info module? The "Introspectable" characteristic is usually meaningful when developing library? 2. Does "Derivable" means "the execution of application code written with ash could be easily predicted."? I am preparing an ash in-house seminar, so I need to understand about this....

Where is the right place to perform transformation on form data before database insert?

Greetings, I have a form that will contain plain text in AsciiDoc format. I would like to convert the AsciiDoc to HTML and store it alongside the original in the database. I'm having a hard time understanding where the best place to do this is. I thought it would be a good candidate for an Ash Calculation, but the examples don't seem to deal with this kind of thing, so I wondered if it was an anti-pattern. In the spirit of "try the simplest thing that will work", I could just do it in the handle_events for creating and updating the resources. Is that a decent approach? Am I overthinking it?...

Check if an identity exists in a before_action

I'm not quite sure how to accomplish this in Ash: I'm uploading files to GCS and want to make sure if the hash of the file matches one I already have, I don't upload it again. The upload happens in a before_action on create right now. The hash of the file is an identity, and I thought eager checking would prevent the upload but it doesn't seem to. I'd like the create_with_binary to return the original record if it exists (without uploading) or upload and create a new record if necessary. So basically find_or_create....