class ActiveGraphql::Client
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
Attributes
config[R]
Public Class Methods
new(config)
click to toggle source
# File lib/active_graphql/client.rb, line 14 def initialize(config) @config = config.dup @adapter_class = @config.delete(:adapter) end
Public Instance Methods
adapter()
click to toggle source
# 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)
click to toggle source
# File lib/active_graphql/client.rb, line 23 def mutation(name) Actions::MutationAction.new(name: name, client: adapter) end
query(name)
click to toggle source
# File lib/active_graphql/client.rb, line 19 def query(name) Actions::QueryAction.new(name: name, client: adapter) end