class Zenaton::Services::GraphQL::CreateWorkflowScheduleMutation

Mutation parameters for scheduling a Task

Public Class Methods

new(workflow, cron, app_env) click to toggle source

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

# File lib/zenaton/services/graph_ql/create_workflow_schedule_mutation.rb, line 14
def initialize(workflow, cron, app_env)
  super
  @workflow = workflow
  @cron = cron
  @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/create_workflow_schedule_mutation.rb, line 23
def body
  { 'query' => query, 'variables' => variables }
end
raw_query() click to toggle source

The query to be executed

# File lib/zenaton/services/graph_ql/create_workflow_schedule_mutation.rb, line 28
        def raw_query
          <<~GQL
            mutation ($input: CreateWorkflowScheduleInput!) {
              createWorkflowSchedule(input: $input) {
                schedule {
                  id
                }
              }
            }
          GQL
        end
variables() click to toggle source

The variables used in the query

# File lib/zenaton/services/graph_ql/create_workflow_schedule_mutation.rb, line 41
def variables
  { 'input' => input }
end

Private Instance Methods

input() click to toggle source
# File lib/zenaton/services/graph_ql/create_workflow_schedule_mutation.rb, line 47
def input
  {
    'intentId' => intent_id,
    'environmentName' => @app_env,
    'cron' => @cron,
    'customId' => @workflow.id.try(:to_s),
    'workflowName' => workflow_name,
    'canonicalName' => @workflow.class.name,
    'programmingLanguage' => 'RUBY',
    'properties' => @serializer.encode(@properties.from(@workflow))
  }
end