Ash FrameworkAF
Ash Framework3y ago
12 replies
barnabasj

no data in Ash.DataLayer.Simple

I have this action in one of my resources

read :read do
      argument :ref, :string do
        allow_nil? false
      end

      get? true

      prepare fn query, _ ->
        Ash.Query.before_action(query, fn query ->
          case Api.quote(%Input{
                 option_ref_id: query.arguments.ref
               }) do
            {:ok, response} ->
              data =
                response
                |> Map.get(:body)
                |> get_in(["data", "hotelX", "quote", "optionQuote"])
                |> JdlEngine.Util.Json.json_to_elixir()
                |> Map.put(:id, query.arguments.ref)
                |> IO.inspect(label: :data)

              query = Ash.DataLayer.Simple.set_data(query, [data])

              IO.inspect(Map.from_struct(query))

              query

            error ->
              error
          end
        end)
      end
    end


I can see that ASh.DataLayer.Simple.set_data is called with the correct value, but I always get a %Ash.Error.SimpleDataLayer.NoDataProvidederror back.

Not sure what I'm doing wrong

Thanks in advance
Was this page helpful?