Class: GraphQL::ScalarType

Inherits:
BaseType show all
Extended by:
Define::InstanceDefinable::DeprecatedDefine
Defined in:
lib/graphql/scalar_type.rb

Defined Under Namespace

Modules: NoOpCoerce

Instance Attribute Summary

Attributes inherited from BaseType

#ast_node, #default_relay, #default_scalar, #description, #introspection, #name

Instance Method Summary collapse

Methods included from Define::InstanceDefinable::DeprecatedDefine

define

Methods inherited from BaseType

#==, #coerce_input, #coerce_isolated_input, #coerce_isolated_result, #default_relay?, #default_scalar?, #get_field, #initialize_copy, #introspection?, #list?, #non_null?, resolve_related_type, #resolve_type, #to_definition, #to_list_type, #to_non_null_type, #to_s, #type_class, #unwrap, #valid_input?, #valid_isolated_input?, #validate_input, #validate_isolated_input

Methods included from Relay::TypeExtensions

#connection_type, #define_connection, #define_edge, #edge_type

Methods included from Define::InstanceDefinable

#define, #deprecated_define, #initialize_copy, #metadata, #redefine

Methods included from Define::NonNullWithBang

#!

Constructor Details

#initializeScalarType

Returns a new instance of ScalarType.



16
17
18
19
# File 'lib/graphql/scalar_type.rb', line 16

def initialize
  super
  self.coerce = NoOpCoerce
end

Instance Method Details

#coerce=(proc) ⇒ Object



21
22
23
24
# File 'lib/graphql/scalar_type.rb', line 21

def coerce=(proc)
  self.coerce_input = proc
  self.coerce_result = proc
end

#coerce_input=(coerce_input_fn) ⇒ Object



26
27
28
29
30
# File 'lib/graphql/scalar_type.rb', line 26

def coerce_input=(coerce_input_fn)
  if !coerce_input_fn.nil?
    @coerce_input_proc = ensure_two_arg(coerce_input_fn, :coerce_input)
  end
end

#coerce_result(value, ctx = nil) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/graphql/scalar_type.rb', line 32

def coerce_result(value, ctx = nil)
  if ctx.nil?
    warn_deprecated_coerce("coerce_isolated_result")
    ctx = GraphQL::Query::NullContext
  end
  @coerce_result_proc.call(value, ctx)
end

#coerce_result=(coerce_result_fn) ⇒ Object



40
41
42
43
44
# File 'lib/graphql/scalar_type.rb', line 40

def coerce_result=(coerce_result_fn)
  if !coerce_result_fn.nil?
    @coerce_result_proc = ensure_two_arg(coerce_result_fn, :coerce_result)
  end
end

#kindObject



46
47
48
# File 'lib/graphql/scalar_type.rb', line 46

def kind
  GraphQL::TypeKinds::SCALAR
end