Class: Graphlyte::Syntax::Operation
- Defined in:
- lib/graphlyte/syntax.rb
Overview
An operation represents a top-level executable definition of a query, mutation or a subscription. See: spec.graphql.org/October2021/#sec-Language.Operations
Instance Attribute Summary collapse
-
#directives ⇒ Object
Returns the value of attribute directives.
-
#name ⇒ Object
Returns the value of attribute name.
-
#selection ⇒ Object
Returns the value of attribute selection.
-
#type ⇒ Object
Returns the value of attribute type.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
- #executable? ⇒ Boolean
-
#initialize(type: nil, **args) ⇒ Operation
constructor
A new instance of Operation.
- #valid? ⇒ Boolean
- #valid_type? ⇒ Boolean
Methods inherited from Data
#==, attr_accessor, attr_reader, attributes, #dup, #eql?, #hash, #inspect
Constructor Details
#initialize(type: nil, **args) ⇒ Operation
Returns a new instance of Operation.
16 17 18 19 |
# File 'lib/graphlyte/syntax.rb', line 16 def initialize(type: nil, **args) super(**args) self.type = type if type end |
Instance Attribute Details
#directives ⇒ Object
Returns the value of attribute directives.
14 15 16 |
# File 'lib/graphlyte/syntax.rb', line 14 def directives @directives end |
#name ⇒ Object
Returns the value of attribute name.
14 15 16 |
# File 'lib/graphlyte/syntax.rb', line 14 def name @name end |
#selection ⇒ Object
Returns the value of attribute selection.
14 15 16 |
# File 'lib/graphlyte/syntax.rb', line 14 def selection @selection end |
#type ⇒ Object
Returns the value of attribute type.
13 14 15 |
# File 'lib/graphlyte/syntax.rb', line 13 def type @type end |
#variables ⇒ Object
Returns the value of attribute variables.
14 15 16 |
# File 'lib/graphlyte/syntax.rb', line 14 def variables @variables end |
Instance Method Details
#executable? ⇒ Boolean
21 22 23 |
# File 'lib/graphlyte/syntax.rb', line 21 def executable? true end |
#valid? ⇒ Boolean
25 26 27 |
# File 'lib/graphlyte/syntax.rb', line 25 def valid? !selection.empty? && valid_type? end |
#valid_type? ⇒ Boolean
29 30 31 |
# File 'lib/graphlyte/syntax.rb', line 29 def valid_type? %i[query mutation subscription].include?(type) end |