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 can I do a 'like' query or similarity search?

Hi, I am looking to do fuzzy search. So, for example , if the user types in 'dan'. I'd like to return all users whose names or emails include 'dan'. I read through the predicate list here: https://hexdocs.pm/ash/Ash.Filter.html hoping for something like 'like' in SQL, but I didnt see naything. What is the best approach? Here is how my code looks currently:...

Is the structure from the auto-generated graph filters from some spec?

Interesting to observe that by default Ash will generate me a whole tree of options to filter and sort a list inside a graph query. I'm still kind of new to graph. Is this design/structure specific to any single frontend library like Rely or Apollo?...
No description

Nested aggregates and calculations

I have a calculation that looks like this conceptually: ``` some_documentation_created (calculation) refers to: count_of_documented_skills (aggregate) filters by:...

use embedded fields inside expr

I have a resource that contains as one of its attributes another resource that is an embedded one. ```elixir defmodule Pacman.Markets.Property.Contact do @moduledoc false...

Ash JSON API is showing an error when following tutorial

Hello, after taking a break from Phoenix and Ash, I decided to move forward with my side project. When setting up the ash_json_api extension, I got the following error: ``` Compiling 18 files (.ex) error: function plug/2 imported from both Phoenix.Router and Plug.Builder, call is ambiguous...

Trying to better understand filter in the context of AshGraph

I am trying to work through some basics of AshGraph, and in the guide it has you set up a filter with code like: ``` read :query_tickets do argument :representative_id, :uuid...

JSON-API And Calculations

Hi, I have a couple of calculations on my models and they seamlessly work in GraphQL. Now I need to make them accessible from the JSON-API and find no automatic way to address them. Do I need to write an extra-route or how should I approach this?

Applying constraints to embedded union types

I have a resource when an embedded array of union types: ```elixir defmodule MyApi.Package attributes do...

How to: Keyset pagination in AshJsonApi

When I enable keyset pagination in my read action, I get an error
** (KeyError) key :metadata not found in: #SomeAshResource..
** (KeyError) key :metadata not found in: #SomeAshResource..
...

DISTINCT ON LEAST() GREATEST()

SELECT DISTINCT ON (LEAST(author_id, recipient_id), GREATEST(author_id, recipient_id)) id, text, author_id, recipient_id...

Ash.Query.filter creates filter with OR condition instead of AND

Ash.Query.filter function documentation explicitly says that a filter will be added with the AND condition, but it seems that this is not the case when fragments is used. For example, if I do this: ```elixir...

Generated filter expression is incorrect - BUG

Hello, I think I found a bug in Ash's query builder. I have the following filter expression in my resource action: ```elixir...

Filter by struct keys in a read action

So I have an ash actions. It receives a struct as an input. I want to create a filter that filters by values inside the struct. here's a simplified version of the action:...

Transactions

There appears to be several ways to handle transactions, but I'd like to really narrow in on a clean way to handle logging entries from within a transaction. Let's use a simple example such as a Post. So when I create a Post from a Phoenix LiveView, I'd like to call a wrapper action for it such as Post.create_with_log(%{title: title}) Then in my Post resource file, I could possibly: 1) Create a code_interface definition such as define(:create, args: [:title], action: :create_with_log)...

Keyset pagination doesn't seem to use default_limit value

I have this action: ```elixir read :list_by_address do argument :address, :string, allow_nil?: false...

Session params missing for oidc providers using response_mode: form_post (e.g. Azure AD)

I am trying to use the OIDC strategy with Azure AD. Now is Azure requiring to use response_mode: form_post. This requires that the POST callback endpoint is not under CSRF protection (similar to how pow_assent is doing it). The issue is that the user/<strategy> key is not in the session during the callback phase. Am I required to implement a server side session store as pow does it? See the setup below: ...

Testing: How to approach testing

Im trying to write some tests for my ash resources, and want to test errors in particular, is there a recommended way of going about this? The testing docs are a bit anemic, wonder if folks have some strategies here. In particular when matching on ash errors, I have to match on large error structs with the stacktrace. Is there a simplier way of going about this?

Why don't read actions filter by attributes?

Given a read action ``` code_interface do define :read end...

warning: Changeset has already been validated for action :create.

I am getting this warning when trying to set an attribute before submitting a form, since this isn't user provided and I don't want to make the http call if this isn't going to be submitted, is there maybe another way to accomplish this as the warning says this will be an error in the future. ``` case AshPhoenix.Form.submit(socket.assigns.form, params: params, before_submit: fn changeset ->...

Should I use old-fashioned DB lookup tables? What might be some alternatives?

I realize not all mapped values are the same. Some have a very small set number of KVs (int id => 5-point scale). Some have a larger (int id => country code). Some have an indefinite set of KVs. In which cases (if not all) would you recommend DB lookup tables with Ash relationships. Would you recommend an alternative? I had considered for small sets to use a calculation, but I think that works with reads but not writes, right?...