Class: ActiveGraphql::Client
- Inherits:
-
Object
- Object
- ActiveGraphql::Client
- Defined in:
- lib/active_graphql/client.rb,
lib/active_graphql/client/actions.rb,
lib/active_graphql/client/adapters.rb,
lib/active_graphql/client/response.rb,
lib/active_graphql/client/actions/action.rb,
lib/active_graphql/client/actions/query_action.rb,
lib/active_graphql/client/actions/mutation_action.rb,
lib/active_graphql/client/actions/variable_detectable.rb,
lib/active_graphql/client/adapters/graphlient_adapter.rb,
lib/active_graphql/client/actions/action/format_inputs.rb,
lib/active_graphql/client/actions/action/format_outputs.rb,
lib/active_graphql/client/adapters/format_multipart_variables.rb,
lib/active_graphql/client/actions/action/format_variable_inputs.rb,
lib/active_graphql/client/adapters/graphlient_multipart_adapter.rb
Overview
GraphQL client which can be used to make requests to graphql endpoint
Example usage:
client = Client.new(url: 'http://example.com/graphql', headers: { 'Authorization' => 'secret'})
client.query(:users).select(:name).result
Defined Under Namespace
Modules: Actions, Adapters Classes: Response
Instance Method Summary collapse
- #adapter ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #mutation(name) ⇒ Object
- #query(name) ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
14 15 16 17 |
# File 'lib/active_graphql/client.rb', line 14 def initialize(config) @config = config.dup @adapter_class = @config.delete(:adapter) end |
Instance Method Details
#adapter ⇒ Object
27 28 29 30 31 32 |
# File 'lib/active_graphql/client.rb', line 27 def adapter @adapter ||= begin adapter_builder = @adapter_class || Adapters::GraphlientAdapter adapter_builder.new(config) end end |
#mutation(name) ⇒ Object
23 24 25 |
# File 'lib/active_graphql/client.rb', line 23 def mutation(name) Actions::MutationAction.new(name: name, client: adapter) end |
#query(name) ⇒ Object
19 20 21 |
# File 'lib/active_graphql/client.rb', line 19 def query(name) Actions::QueryAction.new(name: name, client: adapter) end |