class Zenaton::Services::GraphQL::DispatchWorkflowMutation

Mutation parameters for executing a workflow

Public Class Methods

new(workflow, app_env) click to toggle source

@raise [Zenaton::InvalidArgumentError] if custom id fails validation

# File lib/zenaton/services/graph_ql/dispatch_workflow_mutation.rb, line 14
def initialize(workflow, app_env)
  super
  @workflow = workflow
  @app_env = app_env
  validate_custom_id
end

Public Instance Methods

body() click to toggle source

The body of the GraphQL request

# File lib/zenaton/services/graph_ql/dispatch_workflow_mutation.rb, line 22
def body
  { 'query' => query, 'variables' => variables }
end
raw_query() click to toggle source

The query to be executed

# File lib/zenaton/services/graph_ql/dispatch_workflow_mutation.rb, line 27
        def raw_query
          <<~GQL
            mutation dispatchWorkflow($input: DispatchWorkflowInput!) {
              dispatchWorkflow(input: $input) {
                workflow {
                  id
                }
              }
            }
          GQL
        end
variables() click to toggle source

rubocop:disable Metrics/MethodLength The variables used in the query

# File lib/zenaton/services/graph_ql/dispatch_workflow_mutation.rb, line 41
def variables
  {
    'input' => {
      'customId' => @workflow.id.try(:to_s),
      'environmentName' => @app_env,
      'intentId' => intent_id,
      'programmingLanguage' => 'RUBY',
      'name' => workflow_name,
      'canonicalName' => @workflow.class.name,
      'data' => @serializer.encode(@properties.from(@workflow))
    }
  }
end