The project is in a healthy, maintained state
For Graphql custom query argument module
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

> 3.12.2

Runtime

> 2.0
 Project Readme

GraphQL::QueryArgument

A simple module for graphql resolver

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'

# `Products < Resolvers::Base`:
#
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