Class: GraphQL::ScalarType
Overview
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from BaseType
#==, #coerce_input, #resolve_type, #to_list_type, #to_non_null_type, #to_s, #unwrap, #valid_input?, #validate_input
included
#!
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
15
16
17
|
# File 'lib/graphql/scalar_type.rb', line 15
def description
@description
end
|
#name ⇒ Object
Returns the value of attribute name.
15
16
17
|
# File 'lib/graphql/scalar_type.rb', line 15
def name
@name
end
|
Instance Method Details
#coerce=(proc) ⇒ Object
17
18
19
20
|
# File 'lib/graphql/scalar_type.rb', line 17
def coerce=(proc)
self.coerce_input = proc
self.coerce_result = proc
end
|
32
33
34
35
36
|
# File 'lib/graphql/scalar_type.rb', line 32
def coerce_input=(proc)
if !proc.nil?
@coerce_input_proc = proc
end
end
|
28
29
30
|
# File 'lib/graphql/scalar_type.rb', line 28
def coerce_non_null_input(value)
@coerce_input_proc.call(value)
end
|
#coerce_result(value) ⇒ Object
38
39
40
|
# File 'lib/graphql/scalar_type.rb', line 38
def coerce_result(value)
@coerce_result_proc.call(value)
end
|
#coerce_result=(proc) ⇒ Object
42
43
44
45
46
|
# File 'lib/graphql/scalar_type.rb', line 42
def coerce_result=(proc)
if !proc.nil?
@coerce_result_proc = proc
end
end
|
#kind ⇒ Object
48
49
50
|
# File 'lib/graphql/scalar_type.rb', line 48
def kind
GraphQL::TypeKinds::SCALAR
end
|
22
23
24
25
26
|
# File 'lib/graphql/scalar_type.rb', line 22
def validate_non_null_input(value)
result = Query::InputValidationResult.new
result.add_problem("Could not coerce value #{JSON.dump(value)} to #{name}") if coerce_non_null_input(value).nil?
result
end
|