AF
Ash Framework
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.
JoinAF
Ash Framework
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.
JoinHow to use Ash.Transform?
Sorry, I know this forum is archived but I think here I can get help faster than on Elixir Forum. I'm posting here the same question I've just posted there.
I need to shift the time_zone of some (DateTime) attributes from a resource. Ideally, I'd like to do it right after records are loaded from db. Is it possible? How?...
Ash.Query getting started docs
I need some help to figure out how to translate Ecto queries into Ash ones. I've already read the docs, but I'm still stucked on simple "SELECT COUNT(*) FROM table" and "SELECT MIN(field) FROM table". Where do I find such explanation? Thanks in advance.
Persist embedded resources as :text instead of :map
In my app I'm using Cocktail (https://hexdocs.pm/cocktail) to manage scheduled events which I'd like to save to a text field using
Cocktail.Schedule.to_i_calendar/1
.
What I have so far:
I use an embedded schema to generate the API used in LV forms and GraphQL...Breaking action chain in a before_action?
Problem Statement:
My webhook receives at-least-once messaging from an external producer, and I want to persist these Events -- ids generated by the producer-- as an Ash Resource, such that only one instance is saved in the database (postgres), and an Oban job is only enqueued once.
I've created a custom
:add
action with the upsert?
feature, and that works great for the Event persistence -- idempotent no-ops on subsequent calls....AshCsv calculations update
I am drafting a little beginner tutorial for Ash, and figure that AshCsv + LiveBook might be a good way of minimal setup + transparency to what has changed in "the database".
I have setup a simple calculation (of a weighed average), and was expecting that once it's been loaded (
Ash.Query.load([:weighed_average])
) the entries would be written to the CSV file. That is not happening.
My question is, what is the right way of getting calculated values back into the file? (Or is this bad practice?)...Does attribute and action order matter? and Upsert fields?
Given Declaration
```
defmodule MyApp.MyContext.Event do
use Ash.Resource, data_layer: AshPostgres.DataLayer
...
Auth0 "Authentication Error" without any helpful details
I followed the instructions for Ash Authentication Phoenix and got password auth working with some help.
Then I tried to switch to Auth0 using this quickstart: https://ash-hq.org/docs/guides/ash_authentication/latest/tutorials/auth0-quickstart
Here are the changes I ended up with https://github.com/dewetblomerus/red/pull/2/files ...
belongs_to does not add _id attributes do resource
The resource with attributes and relationships
```elixir
attributes do
uuid_primary_key :id
create_timestamp :inserted_at...
Bi-directional JSON/GraphQL interfaces
This isn't a feature request; just a question that will help me resolve an architecture question.
Say I have an app with a number of separate services, each running in its own environment. These services need to pass some resources between themselves.
Is there a way to define the resource with JSON or GQL is such a way that this resource can proxy between two services: client code on one service can make a request on the resource, which then forwards to the second service, with the answer being returned to the client?...
Attributes on `many_to_many` join/through resources.
Considering the following resources.
```ex
defmodule Formula do
use Ash.Resource,
data_layer: Ash.DataLayer.Ets...
Policy vs FieldPolicy
I haven't used FieldPolicy before, but lets say I have a :role attribute that I want to control changes to. I.e: :god should be able to create users with all roles, :admin should only be able to create :admin and :user, and :user should not be able to create any roles - but still able to edit their own account i.e: change their email etc. Would a field policy be the place for that these days?
Complex types (postgres)
Is it possible to create (and use) complex types like this
```postgres
CREATE DOMAIN dow AS integer
CHECK(
value BETWEEN 1 and 7...
add_tag but unique
A product has a many_to_many relationship to a tag (via a product_tag resource).
lib/app/shop/resources/product.ex ```elixir [...]...
lib/app/shop/resources/product.ex ```elixir [...]...
How to add_tag? Managing Relationships
I try to adapt https://ash-hq.org/docs/guides/ash/latest/topics/managing-relationships for an application where a
product
which has a many_to_many
relationship to tags
.
lib/app/shop/resources/product.ex
```elixir
defmodule App.Shop.Product do...AshAuthenticationPhoenix Reset Password errors after following the guide
After following the AshAuthenticationPhoenix guide. Everything works except following the reset password link, which raises an error.
I followed this guide https://ash-hq.org/docs/guides/ash_authentication_phoenix/latest/tutorials/getting-started-with-ash-authentication-phoenix
Ended up with this code https://github.com/dewetblomerus/red (This is the relevant commit: https://github.com/dewetblomerus/red/commit/3600d53a565c55dbe3f6dedba6e07138335dfab7)...
many_to_many update problem
I have a
product
which has many_to_many tags
. Creating works. Updating doesn't. Here's the resource code:
lib/app/shop/resources/product.ex
```elixir
defmodule App.Shop.Product do...Identity on `attribute :some_attribute, {:array , EmbeddedResource}`
So if I have the following resource.
```elixir
defmodule Resource do
...
actions do...
GraphQL :type, prefix based on Context?
In the example docs, we have something like the following:
```
defmodule Helpdesk.Support.Ticket do
...omitted......