Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graphql_query_argument

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql_query_argument

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

GraphQL::QueryArgument

A simple query argument for resolver module

Installation

Add this line to your application's Gemfile:

gem 'graphql_query_argument'

And then execute:

$ bundle

Or install it yourself as:

$ gem install graphql_query_argument

Usage

require 'graphql/query_argument'

# In your field resolver
# `Products < Resolvers::Base` & a CategoryQueryInputs & a `CompanyType` GraphQL type:
#
module Resolvers
  class Products < Resolvers::Base
    include GraphQL::QueryArgument

    type [Types::ProductType], null: false

    query_argument :name, type: [String], required: false do |scope, value|
      scope.where(name: value)
    end
    query_argument :categories, type: Types::CategoryQueryInputs, required: false do |scope, value|
      scope.joins(:categories).where(categieies: { **value })
    end
  end
end
# `CompanyType`
class CompanyType < Types::BaseObject
  field :products, null: false, resolver: Resolvers::Products

  def products
    object.products
  end
end
# `CategoryQueryInputs`
module Types
  class CategoryQueryInputs < Types::BaseInputObject
    argument :name, [String], required: false
  end
end

FAQs

Package last updated on 25 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc