Giter VIP home page Giter VIP logo

Comments (5)

dima4p avatar dima4p commented on June 2, 2024

Additionally is my_resource.data always nil after Graphiti::Resource#build.
Of course in the case I set raise_on_missing: false here

from graphiti.

factyy avatar factyy commented on June 2, 2024

@dima4p , from our experience I can tell that it's not a good way to rely on resource.data when the model is not yet saved. If you need to check authorization on the model instance creation step, there is a separate gem for it (assuming you are using ActionPolicy).

from graphiti.

dima4p avatar dima4p commented on June 2, 2024

@dima4p , from our experience I can tell that it's not a good way to rely on resource.data when the model is not yet saved. If you need to check authorization on the model instance creation step, there is a separate gem for it (assuming you are using ActionPolicy).

We are using Pundit. I think, that it is important to have the ability to use Graphiti::Resource#build#data to use the new model for authorization.
Now I have to keep in controller the method "#{singular_table_name}_params" and create an additional instance of Model with #new in order to be able to authorize it.

from graphiti.

factyy avatar factyy commented on June 2, 2024

@dima4p , if you are using Graphiti under the hood, you can hook into model creation via the before_save callback where you will have full access to the newly-built (but not yet saved) model

from graphiti.

factyy avatar factyy commented on June 2, 2024

@dima4p , one more thing: keep in mind that with JSON:API you have the ability to sidepost multiple resources in one request and thus you will have to either parse the whole resource tree yourself or rely on Graphiti with the approach I mentioned above

from graphiti.

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.