Class: Types::RangeInputType

Inherits:
BaseInputObject
  • Object
show all
Defined in:
app/graphql/types/range_input_type.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.[](type, closed = true) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/graphql/types/range_input_type.rb', line 5

def self.[](type, closed = true)
  @subtypes ||= {}

  @subtypes[[type, closed]] ||= Class.new(self) do
    argument :start, type,
             required: closed,
             description: 'Start of the range.'

    argument :end, type,
             required: closed,
             description: 'End of the range.'
  end
end

Instance Method Details

#prepareObject



19
20
21
22
23
24
25
# File 'app/graphql/types/range_input_type.rb', line 19

def prepare
  if self[:end] && self[:start] && self[:end] < self[:start]
    raise ::Gitlab::Graphql::Errors::ArgumentError, 'start must be before end'
  end

  super
end