Class: Zenaton::Services::GraphQL::WorkflowQuery
- Inherits:
-
BaseOperation
- Object
- BaseOperation
- Zenaton::Services::GraphQL::WorkflowQuery
- Defined in:
- lib/zenaton/services/graph_ql/workflow_query.rb
Overview
Query parameters to search for a Workflow
Instance Method Summary collapse
-
#body ⇒ Object
The body of the GraphQL request.
-
#initialize(workflow_name, custom_id, app_env) ⇒ WorkflowQuery
constructor
A new instance of WorkflowQuery.
-
#raw_query ⇒ Object
The query to be executed.
-
#result(response) ⇒ Object
Parses the results of the query.
-
#variables ⇒ Object
The variables used in the query.
Methods inherited from BaseOperation
Constructor Details
#initialize(workflow_name, custom_id, app_env) ⇒ WorkflowQuery
Returns a new instance of WorkflowQuery.
10 11 12 13 14 15 |
# 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 |
Instance Method Details
#body ⇒ Object
The body of the GraphQL request
18 19 20 |
# File 'lib/zenaton/services/graph_ql/workflow_query.rb', line 18 def body { 'query' => query, 'variables' => variables } end |
#raw_query ⇒ Object
The query to be executed
23 24 25 26 27 28 29 30 31 32 |
# 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) ⇒ Object
Parses the results of the query
45 46 47 48 49 50 51 52 53 54 55 |
# 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 ⇒ Object
The variables used in the query
35 36 37 38 39 40 41 42 |
# 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 |