Class: Graphlyte::Syntax::Fragment

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

Overview

A definition of a re-usable chunk of an operation See: spec.graphql.org/October2021/#sec-Language.Fragments

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HasFragmentName

included, #name=

Methods inherited from Data

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

Constructor Details

#initialize(**kwargs) ⇒ Fragment

Returns a new instance of Fragment.



114
115
116
117
# File 'lib/graphlyte/syntax.rb', line 114

def initialize(**kwargs)
  super
  @refers_to = []
end

Instance Attribute Details

#directivesObject

Returns the value of attribute directives.



112
113
114
# File 'lib/graphlyte/syntax.rb', line 112

def directives
  @directives
end

#selectionObject

Returns the value of attribute selection.



112
113
114
# File 'lib/graphlyte/syntax.rb', line 112

def selection
  @selection
end

#type_nameObject

Returns the value of attribute type_name.



112
113
114
# File 'lib/graphlyte/syntax.rb', line 112

def type_name
  @type_name
end

Instance Method Details

#executable?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/graphlyte/syntax.rb', line 131

def executable?
  true
end

#inlineObject



119
120
121
# File 'lib/graphlyte/syntax.rb', line 119

def inline
  InlineFragment.new(type_name, directives, selection)
end

#refers_to(fragment) ⇒ Object



123
124
125
# File 'lib/graphlyte/syntax.rb', line 123

def refers_to(fragment)
  @refers_to << fragment
end

#required_fragmentsObject



127
128
129
# File 'lib/graphlyte/syntax.rb', line 127

def required_fragments
  [self] + @refers_to
end