gordoneliel
AEAsh Elixir
•Created by gordoneliel on 9/22/2023 in #support
Preload relationship during action
yeah what would be nice would be something similar to load, say
preload([:relationships])
and would load the relationships if not already loaded.
For context, I typically publish integration events after actions using Oban as an outbox, and serialize the current state of the resource + some relationships into an Oban job to be sent over a message bus, so I run into this sorta stuff all the time48 replies
AEAsh Elixir
•Created by gordoneliel on 9/22/2023 in #support
Preload relationship during action
Ah that makes sense. I guess what im trying to figure out is whats the recommended way to preload stuff to use down the action + changes pipeline. Is it better to have a special change that preloads this? or do you just do it inline where neede?
48 replies
AEAsh Elixir
•Created by gordoneliel on 9/22/2023 in #support
Preload relationship during action
Hm, it still seems a bit weird since the after actions are supposed to be after the action? so the load should be before this I was assuming.
I tried Api.load, which works in the after action, but its doesnt do any optimization for already loaded relationships it seems. Is it possible to preload in the changeset level before an after action?
48 replies
AEAsh Elixir
•Created by gordoneliel on 9/22/2023 in #support
Preload relationship during action
Also my changes after are in an "after action", will it be preloaded by the time im in the after action?
48 replies
AEAsh Elixir
•Created by gordoneliel on 9/22/2023 in #support
Preload relationship during action
Im curious how the resource gets loaded when it hits an action? For my use case its from the AshJsonApi. Is it possible to preload at that level?
48 replies
AEAsh Elixir
•Created by gordoneliel on 9/22/2023 in #support
Preload relationship during action
I guess im curious why the load happens after and not inline?
48 replies
AEAsh Elixir
•Created by gordoneliel on 9/22/2023 in #support
Preload relationship during action
So the change will just do a fetch?
48 replies
AEAsh Elixir
•Created by gordoneliel on 9/14/2023 in #support
How To: Return a computed relationship in a read.
ah, you are right on, I didnt define it there
25 replies
AEAsh Elixir
•Created by gordoneliel on 9/14/2023 in #support
How To: Return a computed relationship in a read.
same on the relationship field on the attribute level too, id is present, type is null
25 replies
AEAsh Elixir
•Created by gordoneliel on 9/14/2023 in #support
How To: Return a computed relationship in a read.
its included, and it returns the correct includes, just the
type
field is null25 replies
AEAsh Elixir
•Created by gordoneliel on 9/14/2023 in #support
How To: Return a computed relationship in a read.
However, the
type
field in the includes on AshJsonApi is returning null for some reason, maybe something to do with the has_one?25 replies
AEAsh Elixir
•Created by gordoneliel on 9/14/2023 in #support
How To: Return a computed relationship in a read.
On man thats so beautiful! It works
25 replies
AEAsh Elixir
•Created by gordoneliel on 9/14/2023 in #support
How To: Return a computed relationship in a read.
It does load it, but it loads all
Comments
. What I would like is to join Comment on Post, something like so where comment.post_id == post_id and comment.some_attribute == true
, Right now its returning all Comments instead of by a specific filter on the relationship/query25 replies
AEAsh Elixir
•Created by gordoneliel on 9/12/2023 in #support
How to: DateTime validation with compare/2
Thanks, this worked! 🙏
12 replies
AEAsh Elixir
•Created by gordoneliel on 9/14/2023 in #support
How To: Return a computed relationship in a read.
So what im thinking is making this into a relationship on
Post
, so post has_one :top_comment, Comment
. What im trying to figure out now is how to hook this up to the Ash.Query
engine. I think what im looking for is a way to join into Comments against some attribute, and merge that into the Post
25 replies
AEAsh Elixir
•Created by gordoneliel on 9/12/2023 in #support
How to: DateTime validation with compare/2
Doesnt look like
fetch_argument_or_attribute
exists, should I be using get_argument_or_attribute?12 replies
AEAsh Elixir
•Created by gordoneliel on 9/8/2023 in #support
How To: Atomic update with a where clause
Thanks that works! For posterity, This is my change module updating two values atomically:
9 replies
AEAsh Elixir
•Created by gordoneliel on 9/8/2023 in #support
How To: Atomic update with a where clause
Something like so:
9 replies
AEAsh Elixir
•Created by gordoneliel on 9/8/2023 in #support
How To: Atomic update with a where clause
How would you combine this with another attribute? Like say I want the
invoice_status
attribute to only update if the atomic last_invoice_event_ts
is updated? Can that even work? Do I have to dip into a custom action / change for that?9 replies
AEAsh Elixir
•Created by gordoneliel on 9/8/2023 in #support
How To: Atomic update with a where clause
That works @Zach Daniel You're the best!
9 replies