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

How to make 'actor' available in nested forms' action

I have Ash.set_actor(current_user) in the mount function of a liveview that contains a nested form. The create/update actions of the main (posts) and sub form (comments), both of which includes change fn changeset, %{actor: actor}, the variable actor passes the proper user map for post , but nil for comment`. Also tried passing actor like below, but it didn't help either. Is there anything else I need to do to make it available in the nested forms' action as well? ``` AshPhoenix.Form.for_update(post, :update, api: MyPosts, actor: socket.assigns.current_user,...

st_distance vs <-> in ash_geo for nearest neighbor search/filter (knn)

I'm just digging into ash_geo and attempting to implement a knn filter, as described here: https://postgis.net/workshops/postgis-intro/knn.html
Unlike a distance search, the “nearest neighbour” search doesn’t include any measurement restricting how far away candidate geometries might be, features of any distance away will be accepted, as long as they are the nearest....

How to sort on a postgres regex?

I'm trying to extract a number from a text field using regex and sort on it. ``` require Ash.Query ...

PGVector

Is it possible to use pgvector extension? https://github.com/pgvector/pgvector-elixir...

GraphQL API fails if custom type is not allowed via a field_policy

I noticed that if I ask my graphQL API to return a field that is forbidden, if the field is built-in, it will just return the field as null, all the other fields normally (assuming they are not forbidden as-well) and an error in the errors list telling that this field is forbidden. But, if I try the same with a custom type, then I just get the full result as null: ```json...

Postgres reference with non-"id" primary keys

Hey, I have these two resources: ```elixir defmodule Moneybadger.Ledger.Expense do use Ash.Resource, data_layer: AshPostgres.DataLayer...

How to use fragments and not built-in predicates in Ash.Filter keyword list syntax?

The documentation only shows how to use the Ash.Filter keyword list syntax with built-in predicates, how can I use it with fragments or non-built-in predicates? For example, this filter: ```elixir...

parse filter with fields from another resource relationship

I'm using Ash.Filter.parse/2 to generate filters using the list syntax, for example: ```elixir Ash.Filter.parse(Template, [ or: [...

Ash.Resource.ManualRead And Filters

Hi, I’m wrapping an external REST API with an Ash resource and therefor use Ash.Resource.ManualRead. Reading the data is not a problem, but as the REST API is way less capable for filtering, I would like to run the returned data through the Ash filters I applied to the query. I mapped the returned data already to the Ash resource and now have an array of these resources. But how can I now apply the filters from the query? That’s what read!() normally would do, but calling that would lead to...

Group by and count query

Hi, Just got to start to say thanks for creating this awesome library. It seems really cool so far 🚀 I was having a bit of trouble with what seems like a simple SQL query with group by. In Ecto I would write the query like this: ```elixir...

Creating an Identity referencing a key within a :map attribute (postgres-stored jsonb)

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

Do I have to manually make a `node` query in Absinthe to honor Global Object Identification?

I am using a SvelteKit library called Houdini to consume a GraphQL endpoint I am creating in Ash. I've intentionally marked my graphql, queries, list with relay?: true per the docs: https://ash-hq.org/docs/dsl/ash-resource#graphql-queries-list-relay-...

Postgrex error when creating record with AshGeo type

I have a resource which contains an attribute defined as: ```elixir attribute :point, AshGeo.Geometry do description "The underlying PostGIS geometry"...

Suggestion broken with latest ElixirSense

Hi @Zach Daniel, I've found a bug using Spark autocomplete suggestion in vscode with latest ElixirSense release. Issue here https://github.com/ash-project/spark/issues/54 and tried to fix that with a PR here https://github.com/ash-project/spark/pull/55...

GraphQL NewType Non-null?

I'm surfacing a calculated map as its own type in GraphQL and trying to make the fields non-nullable, but can't seem to get it working. I've also tried dropping the allow_nil?s into constraints key. Am I holding it wrong? ```elixir defmodule MyApp.Types.LatLng do use Ash.Type.NewType,...
No description

Filtering by enum attribute

I have an Ash resource that has an enum field status. Im using AshJsonApi to pass in a filter: filter[status]=active,incomplete. This doesnt seem to work out of the box so I implemented a preperation where I do this: ```elixir defp filter_by_status(query) do case Ash.Changeset.get_argument(query, :filter) do %{"status" => statuses} ->...

Notifications warning in migration

I'm getting a warning [warning] Missed 1 notifications in action GF.WebComponents.WebSite.update in the logs when running a new migration that calls an :update action on a resource. I know very little about Ash notifications and how they work. I don't want to disable them globally, because they might be useful in the future. How can I prevent this warning from appearing when the migration runs? ``` 12:39:17.050 [warning] Missed 1 notifications in action GF.WebComponents.WebSite.update. ...

Is there a way to define dsl for new type of attribute?

I've implemented ULID type which is one of alternatives to UUID. I can use it without a problem right now by providing type and default to uuid_primary_key. But wanted to venture into making a small spark extension that adds ulid_primary_key. With my naive approach I wrote something like that: ```elixir defmodule Ash.Ulid.Extension do...

Duplicate input types for GraphQL

Given a resource like this ```elixir defmodule Package attributes do...

Create action commits changes even if return fails due to field policy

Hey @Zach Daniel and @barnabasj j, I noticed a behavior that I'm not sure if it is a rbac bug, an Ash bug or if it is not a bug at all and is by design. I have a resource that I forgot to add the fields field policy inside my rbac rules. Because of that, when I run the create action from that resource, it will fail with this error when returning the value: ```...