Ash FrameworkAF
Ash Framework3y ago
15 replies
edwinofdawn

Returns type

I have a actions likes this
elixir
      update :update_user, :update_user do
        read_action :get_by_token
        identity false
      end
    ....

    update :update_user do
      change fn changeset, struct ->
        changeset
        |> Ash.Changeset.change_attribute(
          :confirmed_at,
          Dates.now()
        )
        |> Ash.Changeset.change_attribute(
          :status,
          :confirmed
        )
        |> Ash.Changeset.after_action(fn changeset, customer ->
              #generate token
          {:ok, %{user: user, token: token}}
        end)
      end

I want to override the default return type which defaults to the resource . and instead return a map type with fields user of type user resource and token of type string.
Was this page helpful?