Class: GraphqlRails::Attributes::Attribute

Inherits:
Object
  • Object
show all
Includes:
Attributable, AttributeConfigurable, InputConfigurable
Defined in:
lib/graphql_rails/attributes/attribute.rb

Overview

contains info about single graphql attribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InputConfigurable

#build_input_attribute, #input_attribute_options, #paginated, #paginated?, #pagination_options, #permit, #permit_input

Methods included from AttributeConfigurable

#deprecated, #deprecation_reason, #group, #groups, #hidden_in_groups, #optional, #property, #required, #same_as

Methods included from Attributable

#field_name, #graphql_model, #initialize_copy, #name, #optional?, #required?, #scalar_type?, #type_name

Constructor Details

#initialize(name) ⇒ Attribute

Returns a new instance of Attribute.



18
19
20
21
22
# File 'lib/graphql_rails/attributes/attribute.rb', line 18

def initialize(name)
  @initial_name = name
  @property = name.to_s
  @attributes ||= {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



16
17
18
# File 'lib/graphql_rails/attributes/attribute.rb', line 16

def attributes
  @attributes
end

Instance Method Details

#field_argsObject



24
25
26
27
28
29
30
31
# File 'lib/graphql_rails/attributes/attribute.rb', line 24

def field_args
  [
    field_name,
    type_parser.type_arg,
    description,
    *field_args_options
  ].compact
end

#field_optionsObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/graphql_rails/attributes/attribute.rb', line 33

def field_options
  {
    method: property.to_sym,
    null: optional?,
    camelize: camelize?,
    groups: groups,
    hidden_in_groups: hidden_in_groups,
    **deprecation_reason_params,
    **extras_options
  }
end