class ArSerializer::GraphQL::FieldClass
Attributes
field[R]
name[R]
Public Class Methods
new(name, field)
click to toggle source
# File lib/ar_serializer/graphql/types.rb, line 19 def initialize(name, field) @name = name @field = field end
Public Instance Methods
args()
click to toggle source
# 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_required?()
click to toggle source
# File lib/ar_serializer/graphql/types.rb, line 41 def args_required? return false if field.arguments == :any field.arguments.any? do |key, type| !key.match?(/\?$/) && !(type.is_a?(Array) && type.include?(nil)) end end
args_ts_type()
click to toggle source
# File lib/ar_serializer/graphql/types.rb, line 48 def args_ts_type return 'any' if field.arguments == :any arg_types = field.arguments.map do |key, type| "#{key}: #{TypeClass.from(type).ts_type}" end "{ #{arg_types.join '; '} }" end
collect_types(types)
click to toggle source
# 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
type()
click to toggle source
# File lib/ar_serializer/graphql/types.rb, line 31 def type TypeClass.from field.type, field.only, field.except end