Class: Zenaton::Services::GraphQL

Inherits:
Object
  • Object
show all
Defined in:
lib/zenaton/services/graphql.rb

Overview

Service that:

  • handles graphql calls

  • translates exceptions into Zenaton specific ones

Constant Summary collapse

CREATE_WORKFLOW_SCHEDULE =
"  mutation ($createWorkflowScheduleInput: CreateWorkflowScheduleInput!) {\n    createWorkflowSchedule(input: $createWorkflowScheduleInput) {\n      schedule {\n        id\n      }\n    }\n  }\n"
CREATE_TASK_SCHEDULE =
"  mutation ($createTaskScheduleInput: CreateTaskScheduleInput!) {\n    createTaskSchedule(input: $createTaskScheduleInput) {\n      schedule {\n        id\n      }\n    }\n  }\n"

Instance Method Summary collapse

Constructor Details

#initialize(http:) ⇒ GraphQL



32
33
34
# File 'lib/zenaton/services/graphql.rb', line 32

def initialize(http:)
  @http = http
end

Instance Method Details

#request(url, query, variables = nil, headers = {}) ⇒ Hash

Makes a GRAPHQL request with some data and sets the correct headers



41
42
43
44
45
46
47
# File 'lib/zenaton/services/graphql.rb', line 41

def request(url, query, variables = nil, headers = {})
  body = { 'query' => query }
  body['variables'] = variables if variables

  res_body = @http.post(url, body, headers)
  handle_response_body(res_body)
end