Class: Zenaton::Services::GraphQL::CreateTaskScheduleMutation

Inherits:
BaseOperation
  • Object
show all
Defined in:
lib/zenaton/services/graph_ql/create_task_schedule_mutation.rb

Overview

Mutation parameters for scheduling a Task

Instance Method Summary collapse

Methods inherited from BaseOperation

#intent_id, #query, #result

Constructor Details

#initialize(task, cron, app_env) ⇒ CreateTaskScheduleMutation

Returns a new instance of CreateTaskScheduleMutation.



10
11
12
13
14
15
# File 'lib/zenaton/services/graph_ql/create_task_schedule_mutation.rb', line 10

def initialize(task, cron, app_env)
  super
  @task = task
  @cron = cron
  @app_env = app_env
end

Instance Method Details

#bodyObject

The body of the GraphQL request



18
19
20
# File 'lib/zenaton/services/graph_ql/create_task_schedule_mutation.rb', line 18

def body
  { 'query' => query, 'variables' => variables }
end

#raw_queryObject

The query to be executed



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/zenaton/services/graph_ql/create_task_schedule_mutation.rb', line 23

def raw_query
  <<~GQL
    mutation ($input: CreateTaskScheduleInput!) {
      createTaskSchedule(input: $input) {
        schedule {
          id
        }
      }
    }
  GQL
end

#variablesObject

The variables used in the query



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zenaton/services/graph_ql/create_task_schedule_mutation.rb', line 36

def variables
  {
    'input' => {
      'intentId' => intent_id,
      'environmentName' => @app_env,
      'cron' => @cron,
      'taskName' => @task.class.name,
      'programmingLanguage' => 'RUBY',
      'properties' => @serializer.encode(@properties.from(@task))
    }
  }
end