class GraphQL::ObjectType

@api deprecated

def all_fields

Returns:
  • (Array) - All fields, including ones inherited from interfaces

Other tags:
    See: [Schema#get_fields] - Get fields with instrumentation
def all_fields
  interface_fields.merge(self.fields).values
end

def get_field(field_name)

Returns:
  • (GraphQL::Field) - The field definition for `field_name` (may be inherited from interfaces)

Other tags:
    See: [Schema#get_field] - Get field with instrumentation
def get_field(field_name)
  fields[field_name] || interface_fields[field_name]
end

def implements(interfaces, inherit: false, **options)

Parameters:
  • inherits (Boolean) -- If true, copy the interfaces' field definitions to this type
  • interfaces (Array) -- add a new interface that this type implements
def implements(interfaces, inherit: false, **options)
  if !interfaces.is_a?(Array)
    raise ArgumentError, "`implements(interfaces)` must be an array, not #{interfaces.class} (#{interfaces})"
  end
  @clean_inherited_fields = nil
  type_memberships = inherit ? @inherited_interface_type_memberships : @structural_interface_type_memberships
  interfaces.each do |iface|
    iface = BaseType.resolve_related_type(iface)
    if iface.is_a?(GraphQL::InterfaceType)
      type_memberships << iface.type_membership_class.new(iface, self, options)
    end
  end
end

def initialize

def initialize
  super
  @fields = {}
  @clean_inherited_fields = nil
  @structural_interface_type_memberships = []
  @inherited_interface_type_memberships = []
end

def initialize_copy(other)

def initialize_copy(other)
  super
  @structural_interface_type_memberships = other.structural_interface_type_memberships.dup
  @inherited_interface_type_memberships = other.inherited_interface_type_memberships.dup
  @fields = other.fields.dup
end

def interface_fields

def interface_fields
  if @clean_inherited_fields
    @clean_inherited_fields
  else
    ensure_defined
    @clean_inherited_fields = {}
    @inherited_interface_type_memberships.each do |type_membership|
      iface = GraphQL::BaseType.resolve_related_type(type_membership.abstract_type)
      if iface.is_a?(GraphQL::InterfaceType)
        @clean_inherited_fields.merge!(iface.fields)
      else
        pp iface
      end
    end
    @clean_inherited_fields
  end
end

def interfaces(ctx = GraphQL::Query::NullContext)

def interfaces(ctx = GraphQL::Query::NullContext)
  ensure_defined
  visible_ifaces = []
  unfiltered = ctx == GraphQL::Query::NullContext
  [@structural_interface_type_memberships, @inherited_interface_type_memberships].each do |tms|
    tms.each do |type_membership|
      if unfiltered || type_membership.visible?(ctx)
        # if this is derived from a class-based object, we have to
        # get the `.graphql_definition` of the attached interface.
        visible_ifaces << GraphQL::BaseType.resolve_related_type(type_membership.abstract_type)
      end
    end
  end
  visible_ifaces
end

def interfaces=(new_interfaces)

Deprecated:
  • Use `implements` instead of `interfaces`.

Parameters:
  • new_interfaces (Array) -- interfaces that this type implements
def interfaces=(new_interfaces)
  @structural_interface_type_memberships = []
  @inherited_interface_type_memberships = []
  @clean_inherited_fields = nil
  implements(new_interfaces, inherit: true)
end

def kind

def kind
  GraphQL::TypeKinds::OBJECT
end

def normalize_interfaces(ifaces)

def normalize_interfaces(ifaces)
  ifaces.map { |i_type| GraphQL::BaseType.resolve_related_type(i_type) }
end

def resolve_type_proc

def resolve_type_proc
  nil
end