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.
JoinFailing to create new user: Missing JWT signing secret
Hello there!
I am trying to create a user from the admin dashboard.
Creation fails, and I get an error message in the console:...
read action returning a boolean
Hi, I'm trying to make a resource to represent some global boolean flags for some features in my application. I'm just having trouble figuring out how to writing an action to return a boolean.
```elixir
defmodule Foo.Bar.LiveFeatureFlags do
use Ash.Resource, data_layer: AshPostgres.DataLayer...
Is there a plug for setting the tenant?
I am building an app where users can belong to different organizations. I want each organization to be it's own tenant ( https://hexdocs.pm/ash/multitenancy.html ). When the user is logged in, they select a tenant, and can only have access to data from that tenant.
Is there a way call set_tenant in a router plug ( similar to Ash.PlugHelpers.set_actor(user) ) so that I can globally set the current tenant, without for any queries that might need it?...
Joining this server encourages posting here :)
If you are moving to Elixir forum, probbably remove that part of the getting started checklist?
Forbid all but one field using field policies
Hello, I need to forbid Anonymous actor access to all fields but id and
status. Basically it's needed for some calulcations but we don't want him to have access to any other data. So I've tried using policies like this:
```elixir
field_policies do
field_policy :status do
authorize_if always()...How 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...