Skip to content

Commit

Permalink
fix: user unpaginated_read for read_one
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Apr 6, 2023
1 parent f104e15 commit a14d9ab
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/ash/api/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1415,9 +1415,18 @@ defmodule Ash.Api do

@doc false
def read_one(api, query, opts) do
api
|> read(query, opts)
|> unwrap_one()
query = Ash.Query.set_api(query, api)

with {:ok, opts} <- Spark.OptionsHelpers.validate(opts, @read_opts_schema),
{:ok, action} <- get_action(query.resource, opts, :read, query.action),
{:ok, action} <- pagination_check(action, query.resource, opts) do
query
|> Ash.Actions.Read.unpaginated_read(query.action, opts)
|> unwrap_one()
else
{:error, error} ->
{:error, error}
end
end

defp unwrap_one({:error, error}) do
Expand Down

0 comments on commit a14d9ab

Please sign in to comment.