Class: GraphQL::InputObjectType

Inherits:
ObjectType show all
Defined in:
lib/graph_ql/input_object_type.rb

Overview

A complex input type for a field argument.

Examples:

An input type with name and number

PlayerInput = GraphQL::InputObjectType.new do |i, types, fields, args|
  i.name("Player")
  i.input_fields({
    name: args.build(type: !types.String)
    number: args.build(type: !types.Int)
  })
end

Instance Method Summary collapse

Methods inherited from ObjectType

#==, #fields, #fields=, #initialize, #interfaces, #to_s

Methods included from DefinitionHelpers::Definable

#attr_definable

Methods included from DefinitionHelpers::NonNullWithBang

#!

Constructor Details

This class inherits a constructor from GraphQL::ObjectType

Instance Method Details

#input_fields(new_fields) ⇒ Object #input_fieldsHash

Overloads:

  • #input_fields(new_fields) ⇒ Object

    Define allowed fields, normalized with StringNamedHash

    Parameters:

    • allowed fields for this input object type

  • #input_fieldsHash

    Read the defined fields for this input type

    Returns:

    • allowed fields for this input object type



23
24
25
26
27
28
# File 'lib/graph_ql/input_object_type.rb', line 23

def input_fields(new_fields=nil)
  if !new_fields.nil?
    @new_fields = GraphQL::DefinitionHelpers::StringNamedHash.new(new_fields).to_h
  end
  @new_fields
end

#kindObject



30
31
32
# File 'lib/graph_ql/input_object_type.rb', line 30

def kind
  GraphQL::TypeKinds::INPUT_OBJECT
end