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_required? ⇒ Boolean
- #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 30 31 |
# File 'lib/ar_serializer/graphql/types.rb', line 24 def args arguments = field.arguments_type return [] unless arguments.is_a?(HashTypeClass) arguments.type.map do |key, type| ArgClass.new key, type end end |
#args_required? ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ar_serializer/graphql/types.rb', line 42 def args_required? arguments_type = field.arguments_type case arguments_type when TSTypeClass true when HashTypeClass arguments_type.type.any? do |k, v| !k.end_with?('?') && !v.is_a?(OptionalTypeClass) end else false end end |
#args_ts_type ⇒ Object
56 57 58 |
# File 'lib/ar_serializer/graphql/types.rb', line 56 def args_ts_type field.arguments_type.ts_type end |
#collect_types(types) ⇒ Object
37 38 39 40 |
# File 'lib/ar_serializer/graphql/types.rb', line 37 def collect_types(types) field.arguments_type.collect_types types type.collect_types types end |