Class: GQLi::Mutation

Inherits:
Base
  • Object
show all
Defined in:
lib/gqli/mutation.rb

Overview

Mutation node

Instance Attribute Summary

Attributes inherited from Base

#__depth, #__name, #__nodes

Instance Method Summary collapse

Methods inherited from Base

#___, #__enum, #__node, #__on, #initialize

Constructor Details

This class inherits a constructor from GQLi::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GQLi::Base

Instance Method Details

#__execute(client) ⇒ Object

Delegates itself to the client to be executed



18
19
20
# File 'lib/gqli/mutation.rb', line 18

def __execute(client)
  client.execute(self)
end

#to_gqlObject

Serializes to a GraphQL string



7
8
9
10
11
12
13
14
15
# File 'lib/gqli/mutation.rb', line 7

def to_gql
  result = <<~GQL
    mutation #{__name ? __name + ' ' : ''}{
    #{__nodes.map(&:to_gql).join("\n")}
    }
  GQL

  result.lstrip
end

#to_sObject

Serializes to a GraphQL string



23
24
25
# File 'lib/gqli/mutation.rb', line 23

def to_s
  to_gql
end