class GraphQL::Client::Schema::ObjectClass

def _definer

def _definer
  @definer
end

def _spreads

def _spreads
  @definer.spreads
end

def errors

Returns Errors collection.

builtin error type.
happen, but if it does we should prefer the field rather than the
It's possible to define "errors" as a field. Ideally this shouldn't

Public: Return errors associated with data.
def errors
  if type = @definer.defined_fields["errors"]
    read_attribute("errors", type)
  else
    @errors
  end
end

def has_attribute?(attr)

def has_attribute?(attr)
  !!@data[attr]
end

def initialize(data = {}, errors = Errors.new, definer = nil)

def initialize(data = {}, errors = Errors.new, definer = nil)
  @data = data
  @casted_data = {}
  @errors = errors
  # If we are not provided a definition, we can use this empty default
  definer ||= ObjectType::WithDefinition.new(self.class, {}, nil, [])
  @definer = definer
  @enforce_collocated_callers = source_definition && source_definition.client.enforce_collocated_callers
end

def inspect

def inspect
  parent = self.class
  until parent.superclass == ObjectClass
    parent = parent.superclass
  end
  ivars = @data.map { |key, value|
    if value.is_a?(Hash) || value.is_a?(Array)
      "#{key}=..."
    else
      "#{key}=#{value.inspect}"
    end
  }
  buf = "#<#{parent.name}".dup
  buf << " " << ivars.join(" ") if ivars.any?
  buf << ">"
  buf
end

def method_missing(name, *args)

def method_missing(name, *args)
  if (attr = self.class::READERS[name]) && (type = @definer.defined_fields[attr])
    if @enforce_collocated_callers
      verify_collocated_path do
        read_attribute(attr, type)
      end
    else
      read_attribute(attr, type)
    end
  elsif (attr = self.class::PREDICATES[name]) && @definer.defined_fields[attr]
    has_attribute?(attr)
  else
    begin
      super
    rescue NoMethodError => e
      type = self.class.type
      if ActiveSupport::Inflector.underscore(e.name.to_s) != e.name.to_s
        raise e
      end
      all_fields = type.respond_to?(:all_fields) ? type.all_fields : type.fields.values
      field = all_fields.find do |f|
        f.name == e.name.to_s || ActiveSupport::Inflector.underscore(f.name) == e.name.to_s
      end
      unless field
        raise UnimplementedFieldError, "undefined field `#{e.name}' on #{type.graphql_name} type. https://github.com/github-community-projects/graphql-client/blob/master/guides/unimplemented-field-error.md"
      end
      if @data.key?(field.name)
        raise ImplicitlyFetchedFieldError, "implicitly fetched field `#{field.name}' on #{type} type. https://github.com/github-community-projects/graphql-client/blob/master/guides/implicitly-fetched-field-error.md"
      else
        raise UnfetchedFieldError, "unfetched field `#{field.name}' on #{type} type. https://github.com/github-community-projects/graphql-client/blob/master/guides/unfetched-field-error.md"
      end
    end
  end
end

def read_attribute(attr, type)

def read_attribute(attr, type)
  @casted_data.fetch(attr) do
    @casted_data[attr] = type.cast(@data[attr], @errors.filter_by_path(attr))
  end
end

def respond_to_missing?(name, priv)

def respond_to_missing?(name, priv)
  if (attr = self.class::READERS[name]) || (attr = self.class::PREDICATES[name])
    @definer.defined_fields.key?(attr) || super
  else
    super
  end
end

def source_definition

def source_definition
  @definer.definition
end

def to_h

Returns Hash

Public: Returns the raw response data
def to_h
  @data
end

def verify_collocated_path

def verify_collocated_path
  location = caller_locations(2, 1)[0]
  CollocatedEnforcement.verify_collocated_path(location, source_definition.source_location[0]) do
    yield
  end
end