class Zenaton::Services::GraphQL::WorkflowQuery

Query parameters to search for a Workflow

Public Class Methods

new(workflow_name, custom_id, app_env) click to toggle source
# File lib/zenaton/services/graph_ql/workflow_query.rb, line 10
def initialize(workflow_name, custom_id, app_env)
  super
  @workflow_name = workflow_name
  @custom_id = custom_id
  @app_env = app_env
end

Public Instance Methods

body() click to toggle source

The body of the GraphQL request

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

The query to be executed

# File lib/zenaton/services/graph_ql/workflow_query.rb, line 23
        def raw_query
          <<~GQL
            query ($workflowName: String, $customId: ID, $environmentName: String, $programmingLanguage: String) {
              findWorkflow(environmentName: $environmentName, programmingLanguage: $programmingLanguage, customId: $customId, name: $workflowName) {
                name
                properties
              }
            }
          GQL
        end
result(response) click to toggle source

Parses the results of the query

# File lib/zenaton/services/graph_ql/workflow_query.rb, line 45
def result(response)
  data = response['data']
  raise Zenaton::ExternalError, format_errors(response) unless data

  return nil if data['findWorkflow'].nil?

  @properties.object_from(
    data['findWorkflow']['name'],
    @serializer.decode(data['findWorkflow']['properties'])
  )
end
variables() click to toggle source

The variables used in the query

# File lib/zenaton/services/graph_ql/workflow_query.rb, line 35
def variables
  {
    'customId' => @custom_id,
    'environmentName' => @app_env,
    'programmingLanguage' => 'RUBY',
    'workflowName' => @workflow_name
  }
end