Module: TimeFrameArguments

Extended by:
ActiveSupport::Concern
Included in:
Resolvers::MilestonesResolver
Defined in:
app/graphql/resolvers/concerns/time_frame_arguments.rb

Instance Method Summary collapse

Instance Method Details

#validate_timeframe_params!(args) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/graphql/resolvers/concerns/time_frame_arguments.rb', line 16

def validate_timeframe_params!(args)
  return unless args[:start_date].present? || args[:end_date].present?

  error_message =
    if args[:start_date].nil? || args[:end_date].nil?
      "Both startDate and endDate must be present."
    elsif args[:start_date] > args[:end_date]
      "startDate is after endDate"
    end

  if error_message
    raise Gitlab::Graphql::Errors::ArgumentError, error_message
  end
end