2021-01-03 14:25:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
class RangeInputType < BaseInputObject
|
|
|
|
def self.[](type, closed = true)
|
|
|
|
@subtypes ||= {}
|
|
|
|
|
|
|
|
@subtypes[[type, closed]] ||= Class.new(self) do
|
|
|
|
argument :start, type,
|
|
|
|
required: closed,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'The start of the range.'
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
argument :end, type,
|
|
|
|
required: closed,
|
2021-03-11 19:13:27 +05:30
|
|
|
description: 'The end of the range.'
|
2021-01-03 14:25:43 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def prepare
|
|
|
|
if self[:end] && self[:start] && self[:end] < self[:start]
|
|
|
|
raise ::Gitlab::Graphql::Errors::ArgumentError, 'start must be before end'
|
|
|
|
end
|
|
|
|
|
|
|
|
to_h
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|