Class: GraphqlRails::Attributes::TypeParser

Inherits:
Object
  • Object
show all
Includes:
TypeParseable
Defined in:
lib/graphql_rails/attributes/type_parser.rb

Overview

converts string value in to GraphQL type

Defined Under Namespace

Classes: NotSupportedFeature

Constant Summary

Constants included from TypeParseable

GraphqlRails::Attributes::TypeParseable::GRAPHQL_BASE_TYPES, GraphqlRails::Attributes::TypeParseable::RAW_GRAPHQL_TYPES, GraphqlRails::Attributes::TypeParseable::TYPE_MAPPING, GraphqlRails::Attributes::TypeParseable::WRAPPER_TYPES

Instance Method Summary collapse

Methods included from TypeParseable

#core_scalar_type?, #graphql_model, #graphql_type_object, #raw_graphql_type?, #unwrapped_scalar_type

Constructor Details

#initialize(unparsed_type, paginated: false) ⇒ TypeParser

Returns a new instance of TypeParser.



20
21
22
23
# File 'lib/graphql_rails/attributes/type_parser.rb', line 20

def initialize(unparsed_type, paginated: false)
  @unparsed_type = unparsed_type
  @paginated = paginated
end

Instance Method Details

#graphql_typeObject



29
30
31
32
33
34
35
36
37
# File 'lib/graphql_rails/attributes/type_parser.rb', line 29

def graphql_type
  return unparsed_type if raw_graphql_type?

  if list?
    parsed_list_type
  else
    parsed_inner_type
  end
end

#paginated?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/graphql_rails/attributes/type_parser.rb', line 25

def paginated?
  @paginated
end

#type_argObject



39
40
41
42
43
44
45
46
47
# File 'lib/graphql_rails/attributes/type_parser.rb', line 39

def type_arg
  if paginated?
    paginated_type_arg
  elsif list?
    list_type_arg
  else
    raw_unwrapped_type
  end
end