Giter Club home page Giter Club logo

Comments (3)

zachdaniel avatar zachdaniel commented on September 19, 2024

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.

sb8244 avatar sb8244 commented on September 19, 2024

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.

zachdaniel avatar zachdaniel commented on September 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.