Ash 3.0 Teasers!

Here is another idea.

First a disclaimer, I didn’t think too deep about this, so I’m not sure how relevant it is, it is just something that I particularly had problems before.

I was wondering if we could have a more “low level” version of Ash.Query in Ash 3.0.

Basically what I mean by that is having something that is closer to what Ecto.Query has, in other words, having a low level API that is closer to raw sql.

I know that we can get an Ecto.Query from an Ash.Query via the data_layer_query function, but after we transform it into an Ecto.Query we can’t go back, that means that some functionality of Ash is lost (for example, support for pagination).

Another thing that bothered me a little bit is the requirement to create a calculation when trying to sort data via another resource field, for example:

defmodule ResourceA do
  attributes do
    attribute :score, :decimal
  end
end

defmodule ResourceB do
  relationships do
    belongs_to :resource_a, ResourceA
  end

  calculations do
    calculate :score, :decimal do
      calculation expr(resource_a.score)
    end
  end
end

It would be great if I could just express directly that I want to sort by ResourceA score attribute in ResourceB without having to create that calculation.