class GraphQL::ObjectType


end
end
}
&& stars = stars.limit(args)
stars = object.cast.stars
resolve -> (object, args, ctx) {
arguments :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 initialize

def initialize
  @fields = {}
  @dirty_interfaces = []
end

def interface_fields

Create a {name => defn} hash for fields inherited from interfaces
def interface_fields
  interfaces.reduce({}) do |memo, iface|
    memo.merge!(iface.fields)
  end
end

def interfaces

def interfaces
  @clean_interfaces ||= begin
    ensure_defined
    @dirty_interfaces.map { |i_type| GraphQL::BaseType.resolve_related_type(i_type) }
  rescue
    @dirty_interfaces
  end
end

def interfaces=(new_interfaces)

Parameters:
  • new_interfaces (Array) -- interfaces that this type implements
def interfaces=(new_interfaces)
  @clean_interfaces = nil
  @dirty_interfaces = new_interfaces
end

def kind

def kind
  GraphQL::TypeKinds::OBJECT
end