Class: Types::ColorType

Inherits:
BaseScalar
  • Object
show all
Defined in:
app/graphql/types/color_type.rb

Class Method Summary collapse

Class Method Details

.coerce_input(value, ctx) ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/graphql/types/color_type.rb', line 12

def self.coerce_input(value, ctx)
  color = Gitlab::Color.of(value)
  raise GraphQL::CoercionError, 'Not a color' unless color.valid?

  color
rescue ArgumentError => e
  raise GraphQL::CoercionError, e.message
end

.coerce_result(value, ctx) ⇒ Object



21
22
23
# File 'app/graphql/types/color_type.rb', line 21

def self.coerce_result(value, ctx)
  value.to_s
end