Class: Graphlyte::Schema::Type

Inherits:
Data
  • Object
show all
Defined in:
lib/graphlyte/schema.rb

Overview

A full type definition.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#==, attr_accessor, attr_reader, attributes, #dup, #eql?, #hash, #inspect

Constructor Details

#initializeType

Returns a new instance of Type.



84
85
86
87
88
89
90
91
# File 'lib/graphlyte/schema.rb', line 84

def initialize(**)
  super
  @fields ||= {}
  @input_fields ||= {}
  @interfaces ||= []
  @enums ||= {}
  @possible_types ||= []
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



81
82
83
# File 'lib/graphlyte/schema.rb', line 81

def description
  @description
end

#enumsObject (readonly)

Returns the value of attribute enums.



82
83
84
# File 'lib/graphlyte/schema.rb', line 82

def enums
  @enums
end

#fieldsObject (readonly)

Returns the value of attribute fields.



82
83
84
# File 'lib/graphlyte/schema.rb', line 82

def fields
  @fields
end

#input_fieldsObject (readonly)

Returns the value of attribute input_fields.



82
83
84
# File 'lib/graphlyte/schema.rb', line 82

def input_fields
  @input_fields
end

#interfacesObject (readonly)

Returns the value of attribute interfaces.



82
83
84
# File 'lib/graphlyte/schema.rb', line 82

def interfaces
  @interfaces
end

#kindObject

Returns the value of attribute kind.



81
82
83
# File 'lib/graphlyte/schema.rb', line 81

def kind
  @kind
end

#nameObject

Returns the value of attribute name.



81
82
83
# File 'lib/graphlyte/schema.rb', line 81

def name
  @name
end

#possible_typesObject (readonly)

Returns the value of attribute possible_types.



82
83
84
# File 'lib/graphlyte/schema.rb', line 82

def possible_types
  @possible_types
end

Class Method Details

.from_schema_response(data) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/graphlyte/schema.rb', line 93

def self.from_schema_response(data)
  new(
    kind: data['kind'].to_sym,
    name: data['name'],
    description: data['description'],
    fields: Schema.entity_map(Field, data['fields']),
    input_fields: Schema.entity_map(InputValue, data['inputFields']),
    enums: Schema.entity_map(Enum, data['enumValues']),
    interfaces: Schema.entity_list(TypeRef, data['interfaces']),
    possible_types: Schema.entity_list(TypeRef, data['possibleTypes'])
  )
end