Sha256: e54fc1b6c39f22eb2800a46cc29f8a438c7f4a4c709b4c45ac35d0c401387586

Contents?: true

Size: 1.51 KB

Versions: 8

Compression:

Stored size: 1.51 KB

Contents

require_relative 'base_scalar_comparison_input_type'
require 'arel'

module GraphQL
  module Filters
    module InputTypes
      class NumericComparisonInputType
        include CachedClass

        resolve_cache_miss do |value_type, klass|
          klass.new BaseScalarComparisonInputType[value_type] do
            argument :greater_than,
                     value_type,
                     prepare: lambda { |value, _context|
                       lambda { |scope, column_name|
                         scope.where.not(column_name => (..value))
                       }
                     }
            argument :greater_than_or_equals_to,
                     value_type,
                     prepare: lambda { |value, _context|
                       lambda { |scope, column_name|
                         scope.where(column_name => (value..))
                       }
                     }
            argument :less_than,
                     value_type,
                     prepare: lambda { |value, _context|
                       lambda { |scope, column_name|
                         scope.where(column_name => (...value))
                       }
                     }
            argument :less_than_or_equals_to,
                     value_type,
                     prepare: lambda { |value, _context|
                       lambda { |scope, column_name|
                         scope.where(column_name => (..value))
                       }
                     }
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-filters-1.0.7 lib/graphql/filters/input_types/numeric_comparison_input_type.rb
graphql-filters-1.0.6 lib/graphql/filters/input_types/numeric_comparison_input_type.rb
graphql-filters-1.0.5 lib/graphql/filters/input_types/numeric_comparison_input_type.rb
graphql-filters-1.0.4 lib/graphql/filters/input_types/numeric_comparison_input_type.rb
graphql-filters-1.0.3 lib/graphql/filters/input_types/numeric_comparison_input_type.rb
graphql-filters-1.0.2 lib/graphql/filters/input_types/numeric_comparison_input_type.rb
graphql-filters-1.0.1 lib/graphql/filters/input_types/numeric_comparison_input_type.rb
graphql-filters-1.0.0 lib/graphql/filters/input_types/numeric_comparison_input_type.rb