Code Monkey home page Code Monkey logo

Comments (4)

rmosolgo avatar rmosolgo commented on September 26, 2024 1

Thanks for sharing that background info. What do you think of using .to_unsafe_h?

Yes, ActionController::Parameters mostly works for variables since the keys are referenced by name. But one_of requires mass access (.size), which ActionController::Parameters doesn't allow. Maybe it'd be theoretically possible to call .permit(...) and whitelist incoming keys, but that would require either significant ahead-of-time analysis (to know what keys the incoming query string expects to use) or additional runtime processing (eg, each argument and input object manually .permiting its keys). Since calling .to_unsafe_h is much easier, and doesn't cause any security issues in this case, I'm happy recommending it. Do you think it's a good fit in your case?

from graphql-ruby.

rmosolgo avatar rmosolgo commented on September 26, 2024

Hey, sorry for the trouble and thanks for the detailed report. The gem's current suggestion is to use .to_unsafe_h on incoming parameters:

when ActionController::Parameters
variables_param.to_unsafe_hash # GraphQL-Ruby will validate name and type of incoming variables.

Although it's not usually the right thing to do, I think it makes sense in GraphQL's case because the query itself will validate the variable values.

What do you think of that approach?

from graphql-ruby.

maciesielka avatar maciesielka commented on September 26, 2024

The gem's current suggestion is to use .to_unsafe_h on incoming parameters:

👋🏻 I should've mentioned in my report that I'd seen that recommended in another not-quite-the-same-but-similar issue and tried it out but it ended up creating some additional side-quests in my real-world use case. Some of those complications on my end are worth solving on their own, but I figured I'd reach out about the support story since it seems unexpected that ActionController::Parameters are largely supported as variables, unless you happen to make use of one_of.

from graphql-ruby.

maciesielka avatar maciesielka commented on September 26, 2024

Yup the reasoning makes sense to me and I think we'll be able to make that conversion. Appreciate the help!

from graphql-ruby.

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.