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

Deleting resources that have existing relationships

Version info:
* ash 2.9.11 4baa454f
* ash_postgres 1.3.28 aa32bf2b
* ash 2.9.11 4baa454f
* ash_postgres 1.3.28 aa32bf2b
...

Aggregates with resource relationships

Hello! So maybe there's something I'm not quite understanding from the documentation, but say I have a State and City. A state can have many cities, so: ```elixir relationships do...

Few Ash.Flow questions

I've just started playing with Ash.Flow and I've got a few questions. 1) Is it possible to have a branch step with a condition like expr(Money.positive(^arg(:amount))), I've tried and get a Spark DSL error. 2) Is there a neater way to get_by a resource (similar to how we do it for code_interface) than having to define a separate action? - or does this go against the ethos of Ash.Flow, currently it seems slightly disjointed, with one part of the API encouraging one way and providing nice helpers, but another part not being really integrated, I'm assuming this is just me wanting to use it wrong and carry over certain bad habits / not knowing the magic helpers that do exist... 3) Are there plans to have a flow be able to be invoked via a code_interface?...

Tenant not being recognised in load after upgrading to Ash 2.9.21

Hi, I'm trying to upgrade to the latest version of Ash (2.9.21) and my tests are failing after the upgrade. In particular, I have code like this: ```elixir...

Run an create/update action without persisting the data

Is there any way to run a create/update action without persisting it to the db (I'm using postgres)?

Any way to validate a condition from a read actions instead of policies or filters?

So, normally I use filters modules when I want to validate something in read actions (ex. if I want to filter classes of a school (both resources), I pass the school_id and also filter it by checking if the actor is also from that same school. That kind of filter works great for most of the cases, but sometimes I just want to actually check some validation and return an error (or empty list if the error is not possible) without having the add that validation directly in the resulting SQL query. Normally, specially if the validation is more complex, I create a change module that does the validation and return an error if it didn't pass. But I can't use a change module in a read action....

Can't get policies to work with AshGraphql

I have an action, update_customer_registration, which requires a Customer actor. My Customer policy looks like this: ```elixir...

Querying JSON fields

I have this query, ```sql SELECT * FROM users WHERE settings->>'reminder_day' = 'Monday' -- Replace 'Monday' with your specific day...

get selected fields in create/update action

Hi, I have this policy to check if a user is only selecting fields that they are allowed to see. This worked well for reads because it was possible to get the selected/loaded fields from the query. Is it possible to do something similar for mutations ```elixir defmodule Demo.Policies.SelectsAllowedFields do @moduledoc """...

Test coverage for actions

Currently actions for resources can be defined in separate modules using fragments (with use Spark.Dsl.Fragment). During testing, these modules show 0% coverage. What is the best way to improve coverage for them? Same also goes for all resource modules (with use Ash.Resource)...

Possibility to have prepare statement for create, update, delete actions

Hi Zach Question I see that there a possibility to have a prepare statement for the read action but not for the others. Is there a possibility to add them in the future. If not what was the reasoning for it. Reason for asking was to inject the cache for all the actions...

Possible to add notifier to a resource from an extension on another resource?

Is it possible to dynamically (at compile time) add a notifier to a resource, from within the transformer of an extension on another resource?

Migration not keeping varchar size information

Not sure if I found a bug or not. But if I have this attribute in my migration: ```elixir...

What is the equivalent of Ecto's Repo.exists? in Ash?

Let's say I have a Post resource, and I want to create a read action that instead of returning a specific Post, I want it just to check if the post exists and return only true/false just like Ecto's Repo.exists? does. Is that possible with Ash?...

migration_defaults being "rewritten" by another resource

In my system, I have 2 contexts/apis that uses the same table and have a field in common. The first is the User resource inside the Accounts api: ```elixir...

GraphQL Relationship Resolved w/o Context

Hi there, 👋 I have a query like ```...

Intergrating Gaurdian Plugs into AshGraphql

I want implement JWT validation checking using Guardian. Is there an example I could checkout . For context this is for AshGraphQL and I want the check done only when certain actions are called not all. eg I have elixir ``` update :update_customer_registration do accept [...

Authentication.Plug - What to do as an API? I use Phoenix, but not with views. What is provided?

As I'm exploring and trying to setup AshAuthentication I ended up using use AshAuthentication.Plug for a plug, thinking this would provide the same set of routes as the Phoenix view version would, but it doesn't seem like it. I'm not even sure, as the docs aren't clear on this and I'm at this point digging in the code itself. Do I have to implement my own plug and controller(s) for this? I have an Angular frontend, and will maybe consume the same API from native apps later on. And also, does this mean that some features aren't available unless I use Phoenix?...

Auth0 confusion

Hello, I'm trying to setup ash auth with Auth0 I followed the tutorial but I don't understand how the "/auth" routes are created or how should I create them