Ash FrameworkAF
Ash Framework3y ago
15 replies
Jason

Publish :create, ["created", deeply_nested_item_id]

Let's say my resources have this relationship,
chat_room has many posts which then has many comments.

and I want to have this pub_sub definedin comment.ex.
   pub_sub do
     ...
     publish :create, ["created", :chat_room_id]

   relationships do
     belongs_to :post, MyApp.Chat.Post do
       api MyApp.Chat
      ..

   aggregates do
     first  :chat_room_id, :post, :chat_room_id


Unfortuantely, this gives me the following error. What's the right way to do this?

** (Protocol.UndefinedError) protocol String.Chars not implemented for #Ash.NotLoaded<:aggregate> of type Ash.NotLoaded (a struct)


My chat_room_load() function that feeds the data to the form is defined like this.

def chat_room_load() do
  comments =
     Comment
     |> Ash.Query.load([:post, :chat_room_id])
  posts =
     Post
     |> Ash.Query.load([
        comment: comments
        ...
         ])
Was this page helpful?