Class: Graphlyte::Syntax::Field

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

Overview

A discrete piece of information in the Graph See: spec.graphql.org/October2021/#sec-Language.Fields

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

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

Constructor Details

#initialize(**kwargs) ⇒ Field

Returns a new instance of Field.



77
78
79
80
81
82
# File 'lib/graphlyte/syntax.rb', line 77

def initialize(**kwargs)
  super
  @arguments ||= []
  @directives ||= []
  @selection ||= []
end

Instance Attribute Details

#argumentsObject

Returns the value of attribute arguments.



72
73
74
# File 'lib/graphlyte/syntax.rb', line 72

def arguments
  @arguments
end

#asObject

Returns the value of attribute as.



72
73
74
# File 'lib/graphlyte/syntax.rb', line 72

def as
  @as
end

#directivesObject

Returns the value of attribute directives.



72
73
74
# File 'lib/graphlyte/syntax.rb', line 72

def directives
  @directives
end

#nameObject

Returns the value of attribute name.



72
73
74
# File 'lib/graphlyte/syntax.rb', line 72

def name
  @name
end

#selectionObject

Returns the value of attribute selection.



72
73
74
# File 'lib/graphlyte/syntax.rb', line 72

def selection
  @selection
end

#typeObject

type is special: it is not part of the serialized Query, but inferred from the schema. See: editors/annotate_types.rb



75
76
77
# File 'lib/graphlyte/syntax.rb', line 75

def type
  @type
end

Instance Method Details

#simple?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/graphlyte/syntax.rb', line 84

def simple?
  as.nil? && arguments.empty? && directives.empty? && selection.empty?
end