Class: ActiveGraphql::Client::Adapters::GraphlientAdapter
- Inherits:
-
Object
- Object
- ActiveGraphql::Client::Adapters::GraphlientAdapter
- Defined in:
- lib/active_graphql/client/adapters/graphlient_adapter.rb
Overview
Client which makes raw API requests to GraphQL server
Instance Method Summary collapse
- #adapter_config ⇒ Object
-
#initialize(config) ⇒ GraphlientAdapter
constructor
A new instance of GraphlientAdapter.
- #post(action) ⇒ Object
Constructor Details
#initialize(config) ⇒ GraphlientAdapter
Returns a new instance of GraphlientAdapter.
11 12 13 14 |
# File 'lib/active_graphql/client/adapters/graphlient_adapter.rb', line 11 def initialize(config) @url = config[:url] @config = config end |
Instance Method Details
#adapter_config ⇒ Object
23 24 25 26 27 |
# File 'lib/active_graphql/client/adapters/graphlient_adapter.rb', line 23 def adapter_config @adapter_config ||= config.except(:url, :multipart).tap do |new_config| new_config[:http] = GraphlientMultipartAdapter if multipart? end end |
#post(action) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/active_graphql/client/adapters/graphlient_adapter.rb', line 16 def post(action) raw_response = graphql_client.query(action.to_graphql, action.graphql_variables) Response.new(raw_response.data) rescue Graphlient::Errors::GraphQLError => e Response.new(nil, e) end |