Class: ArSerializer::GraphQL::FieldClass
- Inherits:
-
Object
- Object
- ArSerializer::GraphQL::FieldClass
- Includes:
- Serializable
- Defined in:
- lib/ar_serializer/graphql/types.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #args ⇒ Object
- #args_ts_type ⇒ Object
- #collect_types(types) ⇒ Object
-
#initialize(name, field) ⇒ FieldClass
constructor
A new instance of FieldClass.
- #type ⇒ Object
Constructor Details
#initialize(name, field) ⇒ FieldClass
Returns a new instance of FieldClass.
19 20 21 22 |
# File 'lib/ar_serializer/graphql/types.rb', line 19 def initialize(name, field) @name = name @field = field end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
18 19 20 |
# File 'lib/ar_serializer/graphql/types.rb', line 18 def field @field end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
18 19 20 |
# File 'lib/ar_serializer/graphql/types.rb', line 18 def name @name end |
Instance Method Details
#args ⇒ Object
24 25 26 27 28 29 |
# File 'lib/ar_serializer/graphql/types.rb', line 24 def args return [] if field.arguments == :any field.arguments.map do |key, type| ArgClass.new key, type end end |
#args_ts_type ⇒ Object
41 42 43 44 45 46 |
# File 'lib/ar_serializer/graphql/types.rb', line 41 def args_ts_type arg_types = field.arguments.map do |key, type| "#{key}: #{TypeClass.from(type).ts_type}" end "{ #{arg_types.join '; '} }" end |
#collect_types(types) ⇒ Object
35 36 37 38 39 |
# File 'lib/ar_serializer/graphql/types.rb', line 35 def collect_types(types) types[:any] = true if field.arguments == :any args.each { |arg| arg.type.collect_types types } type.collect_types types end |