Class: ActiveGraphql::Client::Actions::MutationAction

Inherits:
Action
  • Object
show all
Defined in:
lib/active_graphql/client/actions/mutation_action.rb

Overview

handles all action details which are specific for mutation type request

Defined Under Namespace

Classes: UnsuccessfullRequestError

Instance Attribute Summary

Attributes inherited from Action

#client, #input_attributes, #meta_attributes, #name, #output_values

Instance Method Summary collapse

Methods inherited from Action

#graphql_variables, #initialize, #inspect, #meta, #reselect, #response, #rewhere, #select, #to_graphql, #where

Methods included from VariableDetectable

#variable_attributes, #variable_value?

Constructor Details

This class inherits a constructor from ActiveGraphql::Client::Actions::Action

Instance Method Details

#typeObject



12
13
14
# File 'lib/active_graphql/client/actions/mutation_action.rb', line 12

def type
  :mutation
end

#update(inputs) ⇒ Object



16
17
18
# File 'lib/active_graphql/client/actions/mutation_action.rb', line 16

def update(inputs)
  where(inputs).response
end

#update!(inputs) ⇒ Object



20
21
22
23
24
25
# File 'lib/active_graphql/client/actions/mutation_action.rb', line 20

def update!(inputs)
  response = where(inputs).response
  return response.result if response.success?

  raise UnsuccessfullRequestError, response.errors.first
end