123456789_123456789_123456789_123456789_123456789_

Class: GraphQL::Client::Schema::ObjectType::WithDefinition

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/graphql/client/schema/object_type.rb

Constant Summary

Class Method Summary

Instance Attribute Summary

::GraphQL::Client::Schema::BaseType - Included

#schema_module

Internal: Get owner schema Module container.

#type

Public: Get associated GraphQL::BaseType with for this class.

Instance Method Summary

::GraphQL::Client::Schema::ObjectType - Included

#cast, #define_class, #define_field,
#gather_selections

Given an AST selection on this object, gather it into #fields if it applies.

::GraphQL::Client::Schema::BaseType - Included

#cast

Internal: Cast JSON value to wrapped value.

#to_list_type

Internal: Get list wrapper of this type class.

#to_non_null_type

Internal: Get non-nullable wrapper of this type class.

Constructor Details

.new(klass, defined_fields, definition, spreads) ⇒ WithDefinition

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 49

def initialize(klass, defined_fields, definition, spreads)
  @klass = klass
  @defined_fields = defined_fields.map do |k, v|
    [-k.to_s, v]
  end.to_h
  @definition = definition
  @spreads = spreads unless spreads.empty?

  @defined_fields.keys.each do |attr|
    name = ActiveSupport::Inflector.underscore(attr)
    @klass::READERS[:"#{name}"] ||= attr
    @klass::PREDICATES[:"#{name}?"] ||= attr
  end
end

Instance Attribute Details

#defined_fields (readonly)

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 31

attr_reader :klass, :defined_fields, :definition

#definition (readonly)

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 31

attr_reader :klass, :defined_fields, :definition

#klass (readonly)

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 31

attr_reader :klass, :defined_fields, :definition

Instance Method Details

#fields

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 37

def fields
  @klass.fields
end

#new(data = {}, errors = Errors.new)

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 64

def new(data = {}, errors = Errors.new)
  @klass.new(data, errors, self)
end

#spreads

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 41

def spreads
  if defined?(@spreads)
    @spreads
  else
    EMPTY_SET
  end
end

#type

[ GitHub ]

  
# File 'lib/graphql/client/schema/object_type.rb', line 33

def type
  @klass.type
end