Class: Artemis::Adapters::CurbAdapter
- Inherits:
-
AbstractAdapter
- Object
- GraphQL::Client::HTTP
- AbstractAdapter
- Artemis::Adapters::CurbAdapter
- Defined in:
- lib/artemis/adapters/curb_adapter.rb
Constant Summary
Constants inherited from AbstractAdapter
AbstractAdapter::DEFAULT_HEADERS, AbstractAdapter::EMPTY_HEADERS
Instance Attribute Summary collapse
-
#multi ⇒ Object
readonly
Returns the value of attribute multi.
Attributes inherited from AbstractAdapter
#pool_size, #service_name, #timeout
Instance Method Summary collapse
- #execute(document:, operation_name: nil, variables: {}, context: {}) ⇒ Object
-
#initialize(uri, service_name:, timeout:, pool_size:, adapter_options: {}) ⇒ CurbAdapter
constructor
A new instance of CurbAdapter.
- #multiplex(queries, context: {}) ⇒ Object
Methods inherited from AbstractAdapter
Constructor Details
#initialize(uri, service_name:, timeout:, pool_size:, adapter_options: {}) ⇒ CurbAdapter
Returns a new instance of CurbAdapter.
16 17 18 19 20 21 |
# File 'lib/artemis/adapters/curb_adapter.rb', line 16 def initialize(uri, service_name: , timeout: , pool_size: , adapter_options: {}) super @multi = Curl::Multi.new @multi.pipeline = Curl::CURLPIPE_MULTIPLEX if defined?(Curl::CURLPIPE_MULTIPLEX) end |
Instance Attribute Details
#multi ⇒ Object (readonly)
Returns the value of attribute multi.
14 15 16 |
# File 'lib/artemis/adapters/curb_adapter.rb', line 14 def multi @multi end |
Instance Method Details
#execute(document:, operation_name: nil, variables: {}, context: {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/artemis/adapters/curb_adapter.rb', line 27 def execute(document:, operation_name: nil, variables: {}, context: {}) body = {} body["query"] = document.to_query_string body["variables"] = variables if variables.any? body["operationName"] = operation_name if operation_name make_request(body, context) end |
#multiplex(queries, context: {}) ⇒ Object
23 24 25 |
# File 'lib/artemis/adapters/curb_adapter.rb', line 23 def multiplex(queries, context: {}) make_request({ _json: queries }, context) end |