Class: GraphQL::ObjectType
- Inherits:
-
Object
- Object
- GraphQL::ObjectType
- 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
Direct Known Subclasses
InputObjectType, InterfaceType, ListType, NonNullType, ScalarType
Defined Under Namespace
Classes: Printer
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#interfaces ⇒ Object
Returns the value of attribute interfaces.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Are these types equivalent? (incl. non-null, list).
- #kind ⇒ Object
-
#to_s ⇒ Object
(also: #inspect)
Print the human-readable name of this type.
Methods included from DefinitionHelpers::DefinedByConfig
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).
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 |