Class: Artemis::Adapters::NetHttpAdapter
- Inherits:
-
AbstractAdapter
- Object
- GraphQL::Client::HTTP
- AbstractAdapter
- Artemis::Adapters::NetHttpAdapter
- Defined in:
- lib/artemis/adapters/net_http_adapter.rb
Direct Known Subclasses
Constant Summary
Constants inherited from AbstractAdapter
AbstractAdapter::DEFAULT_HEADERS, AbstractAdapter::EMPTY_HEADERS
Instance Attribute Summary
Attributes inherited from AbstractAdapter
#pool_size, #service_name, #timeout
Instance Method Summary collapse
-
#connection ⇒ Object
Returns a fresh Net::HTTP object that creates a new connection.
-
#execute(document:, operation_name: nil, variables: {}, context: {}) ⇒ Object
Makes an HTTP request for GraphQL query.
- #multiplex(queries, context: {}) ⇒ Object
Methods inherited from AbstractAdapter
Constructor Details
This class inherits a constructor from Artemis::Adapters::AbstractAdapter
Instance Method Details
#connection ⇒ Object
Returns a fresh Net::HTTP object that creates a new connection.
27 28 29 30 31 32 33 34 |
# File 'lib/artemis/adapters/net_http_adapter.rb', line 27 def connection Net::HTTP.new(uri.host, uri.port).tap do |client| client.use_ssl = uri.scheme == "https" client.open_timeout = timeout client.read_timeout = timeout client.write_timeout = timeout if client.respond_to?(:write_timeout=) end end |
#execute(document:, operation_name: nil, variables: {}, context: {}) ⇒ Object
Makes an HTTP request for GraphQL query.
17 18 19 20 21 22 23 24 |
# File 'lib/artemis/adapters/net_http_adapter.rb', line 17 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
12 13 14 |
# File 'lib/artemis/adapters/net_http_adapter.rb', line 12 def multiplex(queries, context: {}) make_request({ _json: queries }, context) end |