Code Monkey home page Code Monkey logo

Comments (3)

rmosolgo avatar rmosolgo commented on June 8, 2024 1

Yes, that's just what scope_items is for -- sounds good! Please let me know if you have any other questions or trouble with it.

from graphql-ruby.

swalkinshaw avatar swalkinshaw commented on June 8, 2024

Have you looked into the auto-loading argument feature? https://graphql-ruby.org/mutations/mutation_classes.html#auto-loading-arguments

It automatically runs authorized? like you're doing in addition to the loading

from graphql-ruby.

Austin-X avatar Austin-X commented on June 8, 2024

@swalkinshaw Thanks Scott! That auto-loading argument feature you suggested works for all of my mutations which take an Author as an argument.

I have another question which I will demonstrate with an example. In this example, I have a query named allAuthors and another query named all_authors_with_id_less_than_ten as shown in the code snippet below

module Types
  class QueryType < Types::BaseObject
    field :all_authors, [Types::AuthorType], null: false
    def all_authors
      Author.all
    end

    field :all_authors_with_id_less_than_ten, [Types::AuthorType], null: false
    def all_authors_with_id_less_than_ten
      Author.where('id < 10')
    end
  end
end

Now, I want to restrict these two queries to only show authors that have an id of 1. My solution uses scope_items, and I was just wondering if using scope_items is the best way to solve this type of problem.

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.