Class: Graphlyte::Syntax::Operation

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

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

#directivesObject

Returns the value of attribute directives.



14
15
16
# File 'lib/graphlyte/syntax.rb', line 14

def directives
  @directives
end

#nameObject

Returns the value of attribute name.



14
15
16
# File 'lib/graphlyte/syntax.rb', line 14

def name
  @name
end

#selectionObject

Returns the value of attribute selection.



14
15
16
# File 'lib/graphlyte/syntax.rb', line 14

def selection
  @selection
end

#typeObject

Returns the value of attribute type.



13
14
15
# File 'lib/graphlyte/syntax.rb', line 13

def type
  @type
end

#variablesObject

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

Returns:

  • (Boolean)


21
22
23
# File 'lib/graphlyte/syntax.rb', line 21

def executable?
  true
end

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/graphlyte/syntax.rb', line 25

def valid?
  !selection.empty? && valid_type?
end

#valid_type?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/graphlyte/syntax.rb', line 29

def valid_type?
  %i[query mutation subscription].include?(type)
end