class GraphQL::ObjectType


end
end
}
&& stars = stars.limit(args)
stars = object.cast.stars
resolve ->(object, args, ctx) {
argument :limit, types.Int
field :starring, types do
field :cast, CastType
field :director, PersonType
field :runtimeMinutes, !types.Int, property: :runtime_minutes
interfaces [ProductionInterface, DurationInterface]
description “A full-length film or a short film”
name “Movie”
MovieType = GraphQL::ObjectType.define do
@example defining a type for your IMDB clone
This type exposes fields on an object.

def all_fields

Returns:
  • (Array) - All fields, including ones inherited from interfaces
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)
def get_field(field_name)
  fields[field_name] || interface_fields[field_name]
end

def implements(interfaces, inherit: false)

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)
  if !interfaces.is_a?(Array)
    raise ArgumentError, "`implements(interfaces)` must be an array, not #{interfaces.class} (#{interfaces})"
  end
  @clean_interfaces = nil
  @clean_inherited_fields = nil
  dirty_ifaces = inherit ? @dirty_inherited_interfaces : @dirty_interfaces
  dirty_ifaces.concat(interfaces)
end

def initialize

def initialize
  super
  @fields = {}
  @interface_fields = {}
  @dirty_interfaces = []
  @dirty_inherited_interfaces = []
end

def initialize_copy(other)

def initialize_copy(other)
  super
  @clean_interfaces = nil
  @clean_inherited_interfaces = nil
  @dirty_interfaces = other.dirty_interfaces.dup
  @dirty_inherited_interfaces = other.dirty_inherited_interfaces.dup
  @fields = other.fields.dup
end

def interface_fields

def interface_fields
  load_interfaces
  @clean_inherited_fields
end

def interfaces

def interfaces
  load_interfaces
  @clean_interfaces
end

def interfaces=(new_interfaces)

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

Parameters:
  • new_interfaces (Array) -- interfaces that this type implements
def interfaces=(new_interfaces)
  @clean_interfaces = nil
  @clean_inherited_interfaces = nil
  @clean_inherited_fields = nil
  @dirty_inherited_interfaces = []
  @dirty_inherited_fields = {}
  implements(new_interfaces, inherit: true)
end

def kind

def kind
  GraphQL::TypeKinds::OBJECT
end

def load_interfaces

def load_interfaces
  @clean_interfaces ||= begin
    ensure_defined
    clean_ifaces = normalize_interfaces(@dirty_interfaces)
    clean_inherited_ifaces = normalize_interfaces(@dirty_inherited_interfaces)
    inherited_fields = {}
    clean_inherited_ifaces.each do |iface|
      # This will be found later in schema validation:
      if iface.is_a?(GraphQL::InterfaceType)
        inherited_fields.merge!(iface.fields)
      end
    end
    @clean_inherited_fields = inherited_fields
    clean_inherited_ifaces + clean_ifaces
  end
end

def normalize_interfaces(ifaces)

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