Class: GraphQL::ObjectType

Inherits:
Object
  • Object
show all
Includes:
DefinitionHelpers::DefinedByConfig, DefinitionHelpers::NonNullWithBang
Defined in:
lib/graphql/object_type.rb

Overview

This type exposes fields on an object.

@example defining a type for your IMDB clone MovieType = GraphQL::ObjectType.define do name "Movie" description "A full-length film or a short film" interfaces [ProductionInterface, DurationInterface]

 field :runtimeMinutes, !types.Int, property: :runtime_minutes
 field :director, PersonType
 field :cast, CastType
 field :starring, types[PersonType] do
   arguments :limit, types.Int
   resolve -> (object, args, ctx) {
     stars = object.cast.stars
     args[:limit] && stars = stars.limit(args[:limit])
     stars
   }
  end
end

Defined Under Namespace

Classes: Printer

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DefinitionHelpers::DefinedByConfig

included

Methods included from DefinitionHelpers::NonNullWithBang

#!

Instance Attribute Details

#description ⇒ Object

Returns the value of attribute description.



26
27
28
# File 'lib/graphql/object_type.rb', line 26

def description
  @description
end

#fields ⇒ Object

Returns the value of attribute fields.



26
27
28
# File 'lib/graphql/object_type.rb', line 26

def fields
  @fields
end

#interfaces ⇒ Object

Returns the value of attribute interfaces.



26
27
28
# File 'lib/graphql/object_type.rb', line 26

def interfaces
  @interfaces
end

#name ⇒ Object

Returns the value of attribute name.



26
27
28
# File 'lib/graphql/object_type.rb', line 26

def name
  @name
end

Instance Method Details

#==(other) ⇒ Boolean

Returns are these types equivalent? (incl. non-null, list).

Parameters:

Returns:

  • (Boolean) —

    are these types equivalent? (incl. non-null, list)



56
57
58
59
60
61
62
# File 'lib/graphql/object_type.rb', line 56

def ==(other)
  if other.is_a?(GraphQL::ObjectType)
    self.to_s == other.to_s
  else
    super
  end
end

#kind ⇒ Object



43
44
45
# File 'lib/graphql/object_type.rb', line 43

def kind
  GraphQL::TypeKinds::OBJECT
end

#to_s ⇒ Object Also known as: inspect

Print the human-readable name of this type



48
49
50
# File 'lib/graphql/object_type.rb', line 48

def to_s
  Printer.instance.print(self)
end