mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 13:33:20 +12:00
fix: drop proper opts keys when calling api in code interface (#608)
This commit is contained in:
parent
5e93ebe9bd
commit
f5238674a4
1 changed files with 26 additions and 10 deletions
|
@ -449,7 +449,7 @@ defmodule Ash.CodeInterface do
|
||||||
|
|
||||||
unquote(api).run_action(
|
unquote(api).run_action(
|
||||||
action_input,
|
action_input,
|
||||||
Keyword.drop(opts, [:actor, :changeset, :tenant, :authorize?, :tracer])
|
Keyword.drop(opts, [:input, :actor, :tenant, :authorize?, :tracer])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -477,7 +477,8 @@ defmodule Ash.CodeInterface do
|
||||||
end)
|
end)
|
||||||
|
|
||||||
action_input =
|
action_input =
|
||||||
(opts[:input] || unquote(resource))
|
opts[:input]
|
||||||
|
|> Kernel.||(unquote(resource))
|
||||||
|> Ash.ActionInput.for_action(
|
|> Ash.ActionInput.for_action(
|
||||||
unquote(action.name),
|
unquote(action.name),
|
||||||
input,
|
input,
|
||||||
|
@ -486,7 +487,7 @@ defmodule Ash.CodeInterface do
|
||||||
|
|
||||||
unquote(api).run_action!(
|
unquote(api).run_action!(
|
||||||
action_input,
|
action_input,
|
||||||
Keyword.drop(opts, [:actor, :changeset, :authorize?, :tracer])
|
Keyword.drop(opts, [:input, :actor, :tenant, :authorize?, :tracer])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -543,7 +544,14 @@ defmodule Ash.CodeInterface do
|
||||||
if unquote(interface.get? || action.get?) do
|
if unquote(interface.get? || action.get?) do
|
||||||
query
|
query
|
||||||
|> unquote(api).read_one(
|
|> unquote(api).read_one(
|
||||||
Keyword.drop(opts, [:query, :tenant, :authorize?, :actor, :not_found_error?])
|
Keyword.drop(opts, [
|
||||||
|
:query,
|
||||||
|
:not_found_error?,
|
||||||
|
:actor,
|
||||||
|
:tenant,
|
||||||
|
:authorize?,
|
||||||
|
:tracer
|
||||||
|
])
|
||||||
)
|
)
|
||||||
|> case do
|
|> case do
|
||||||
{:ok, nil} ->
|
{:ok, nil} ->
|
||||||
|
@ -563,7 +571,7 @@ defmodule Ash.CodeInterface do
|
||||||
else
|
else
|
||||||
unquote(api).read(
|
unquote(api).read(
|
||||||
query,
|
query,
|
||||||
Keyword.drop(opts, [:query, :tenant, :actor, :authorize?])
|
Keyword.drop(opts, [:query, :actor, :tenant, :authorize?, :tracer])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -621,7 +629,14 @@ defmodule Ash.CodeInterface do
|
||||||
if unquote(interface.get? || action.get?) do
|
if unquote(interface.get? || action.get?) do
|
||||||
query
|
query
|
||||||
|> unquote(api).read_one!(
|
|> unquote(api).read_one!(
|
||||||
Keyword.drop(opts, [:query, :tenant, :authorize?, :actor, :not_found_error?])
|
Keyword.drop(opts, [
|
||||||
|
:query,
|
||||||
|
:not_found_error?,
|
||||||
|
:actor,
|
||||||
|
:tenant,
|
||||||
|
:authorize?,
|
||||||
|
:tracer
|
||||||
|
])
|
||||||
)
|
)
|
||||||
|> case do
|
|> case do
|
||||||
nil ->
|
nil ->
|
||||||
|
@ -638,7 +653,7 @@ defmodule Ash.CodeInterface do
|
||||||
else
|
else
|
||||||
unquote(api).read!(
|
unquote(api).read!(
|
||||||
query,
|
query,
|
||||||
Keyword.drop(opts, [:query, :tenant, :actor, :authorize?])
|
Keyword.drop(opts, [:query, :actor, :tenant, :authorize?, :tracer])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -677,7 +692,7 @@ defmodule Ash.CodeInterface do
|
||||||
|
|
||||||
unquote(api).create(
|
unquote(api).create(
|
||||||
changeset,
|
changeset,
|
||||||
Keyword.drop(opts, [:actor, :changeset, :tenant, :authorize?, :tracer])
|
Keyword.drop(opts, [:changeset, :actor, :tenant, :authorize?, :tracer])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -705,7 +720,8 @@ defmodule Ash.CodeInterface do
|
||||||
end)
|
end)
|
||||||
|
|
||||||
changeset =
|
changeset =
|
||||||
(opts[:changeset] || unquote(resource))
|
opts[:changeset]
|
||||||
|
|> Kernel.||(unquote(resource))
|
||||||
|> Ash.Changeset.for_create(
|
|> Ash.Changeset.for_create(
|
||||||
unquote(action.name),
|
unquote(action.name),
|
||||||
input,
|
input,
|
||||||
|
@ -714,7 +730,7 @@ defmodule Ash.CodeInterface do
|
||||||
|
|
||||||
unquote(api).create!(
|
unquote(api).create!(
|
||||||
changeset,
|
changeset,
|
||||||
Keyword.drop(opts, [:actor, :changeset, :authorize?, :tracer])
|
Keyword.drop(opts, [:changeset, :actor, :tenant, :authorize?, :tracer])
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue