Class: ArSerializer::GraphQL::OrTypeClass

Inherits:
TypeClass
  • Object
show all
Defined in:
lib/ar_serializer/graphql/types.rb

Instance Attribute Summary

Attributes inherited from TypeClass

#except, #only, #type

Instance Method Summary collapse

Methods inherited from TypeClass

#association_type, #description, #fields, from, #initialize, #of_type, #validate!

Constructor Details

This class inherits a constructor from ArSerializer::GraphQL::TypeClass

Instance Method Details

#collect_types(types) ⇒ Object



399
400
401
402
# File 'lib/ar_serializer/graphql/types.rb', line 399

def collect_types(types)
  types[:other] = true
  of_types.map { |t| t.collect_types types }
end

#gql_typeObject



404
405
406
# File 'lib/ar_serializer/graphql/types.rb', line 404

def gql_type
  kind
end

#kindObject



387
388
389
# File 'lib/ar_serializer/graphql/types.rb', line 387

def kind
  'OBJECT'
end

#nameObject



391
392
393
# File 'lib/ar_serializer/graphql/types.rb', line 391

def name
  :other
end

#of_typesObject



395
396
397
# File 'lib/ar_serializer/graphql/types.rb', line 395

def of_types
  type.map { |t| TypeClass.from t, only, except }
end

#sampleObject



408
409
410
# File 'lib/ar_serializer/graphql/types.rb', line 408

def sample
  of_types.first.sample
end

#ts_typeObject



412
413
414
# File 'lib/ar_serializer/graphql/types.rb', line 412

def ts_type
  '(' + of_types.map(&:ts_type).join(' | ') + ')'
end