-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow using Loader with Permit.Ecto.Resolver #8
base: master
Are you sure you want to change the base?
Conversation
I think it could be good to add resolver tests for this. |
:unauthorized | ||
|
||
nil -> | ||
raise Ecto.NoResultsError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a library that depends on Ecto, this is acceptable, but it's possible that it could have a different behaviour since we're not actually firing any query explicitly here. (Related to #1)
authorization_module, | ||
resource_module, | ||
action, | ||
%{use_loader?: true} = meta, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be possible to not have to use an additional use_loader?
option if permit_phoenix/controller.ex
allows differentiating between nil and a function at plug level. (line 365)
|
||
with {_, true} <- | ||
{:pre_auth, authorized?(subject, authorization_module, resource_module, action)}, | ||
resource <- meta[:loader].(params_for_loader), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If in permit_phoenix
the loader/1
function is defined as such:
def loader(resolution_context) do
case unquote(opts)[:loader] do
nil -> nil
loader -> {:loader, unquote(__MODULE__).loader(resolution_context, unquote(opts))}
end
end
you could check here whether loader was not given at all, or it returned nil
d4876a4
to
0181070
Compare
No description provided.