Comments (3)
In Ash, nil
is a valid actor. Currently, require_actor?
's job is to require that all places pass the actor
option, not to ensure that it is not nil
. This is to prevent typos, basically. AshGraphql always sets the actor option, even if one was not provided to it (but it may be nil
). A good argument could be made for that being not the best behavior, but it is currently the designed behavior.
Typically this would be implemented somewhere in the authentication flow, where if authentication fails or no authentication information is present you'd reject the user's request.
It is too late to change the semantics of require_actor?
, unfortunately, but we could potentially add something like validate_actor/1
that gives you the actor and a chance to provide an arbitrary error message about why that actor is invalid.
Then you could accomplish what you want with something like this:
require_actor? true
validate_actor fn nil ->
{:error, "...."}
%User{} = user ->
{:ok, user}
end
from ash_graphql.
Thanks Zach. That's helpful to understand. You're right that my auth flow handles this, it was more of an interim state that felt off. But now I understand so all good.
I didn't have the AshGraphql plug in my pipeline at the time. Not sure if that changes anything.
from ash_graphql.
Shouldn't affect things. I'll close this for now, but if it looks like validate_actor
or some similar set of behavior will help in other cases as well then we'll add it to the roadmap :)
from ash_graphql.
Related Issues (20)
- Error when using `paginate_with: nil` and the default `read` action in Ash 3.0 HOT 1
- Allow paginating nested relationships HOT 3
- Error when creating new records with `managed_relationships` in Ash 3.0
- Allow adding a description at the query/mutation level
- An action that `accept`s attributes does not expose those attributes in the schema HOT 1
- Allow JsonString type to be renamed HOT 2
- Module does not exists
- Type deduplication quirks
- The mutation/custom read action fails in simple data layer resource HOT 2
- Don't generate empty input objects in AshGraphql HOT 1
- Compilng with latest 1.17 RC throws warnings that cause failure to compile when compiling with warnings as errors
- protocol Enumerable not implemented for nil of type Atom HOT 1
- Add a sample runnable query to the generated schema when there is nothing else in it HOT 3
- Filtering by relationship does not work, results in an error HOT 6
- `manual` callback not getting called in the `read_action` of an update mutation HOT 1
- Raised error for `update` mutation, with `read_action` and `Ash.Query.after_action()` HOT 1
- AshGraphql 0.28.1 breaks when resource is in more than one API HOT 2
- Attribute validation escalates to "something went wrong" instead of "invalid attribute" HOT 4
- Igniter Upload Setup
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ash_graphql.