Ash FrameworkAF
Ash Framework3y ago
18 replies
xSHYNE

Ash.Query.load not loading nested relationship?

User |> Ash.Query.load([friendships: [:first, :second]])
|> Accounts.read!()

#Ash.Query<
  resource: User,
  errors: [
    %Ash.Error.Query.InvalidLoad{
      load: :first,
      changeset: nil,
      query: nil,
      error_context: [],
      vars: [],
      path: [:friendships, :load],
      stacktrace: #Stacktrace<>,
      class: :invalid
    },
    %Ash.Error.Query.InvalidLoad{
      load: :second,
      changeset: nil,
      query: nil,
      error_context: [],
      vars: [],
      path: [:friendships, :load],
      stacktrace: #Stacktrace<>,
      class: :invalid
    }
  ]
>

this gives an invalid load BUT:

Friendship |> Ash.Query.load([:first, :second]) |> Accounts.read!()

  #Friendship<
    second: User<>
    first: User<> 

works fine? Why can't I load nested on the parent many_to_many relationship?
Was this page helpful?