Class: Giraph::Remote::Query
- Inherits:
-
Object
- Object
- Giraph::Remote::Query
- Defined in:
- lib/giraph/remote/query.rb
Overview
Field resolver to plug a remote GraphQL query root into a local type
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#call(obj, args, ctx) ⇒ Object
Reconstructs a valid GraphQL root-query from the current field in question, including all variables and params, hands over to connector to execute remotely.
-
#initialize(endpoint, connector, &block) ⇒ Query
constructor
A new instance of Query.
Constructor Details
#initialize(endpoint, connector, &block) ⇒ Query
Returns a new instance of Query.
13 14 15 16 17 |
# File 'lib/giraph/remote/query.rb', line 13 def initialize(endpoint, connector, &block) @endpoint = endpoint @evaluator = block || method(:default_evaluator) @connector = connector end |
Class Method Details
Instance Method Details
#call(obj, args, ctx) ⇒ Object
Reconstructs a valid GraphQL root-query from the current field in question, including all variables and params, hands over to connector to execute remotely.
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/giraph/remote/query.rb', line 22 def call(obj, args, ctx) # Given an evaluator block, continue if only it evaluates to non-nil! return unless (remote_root = @evaluator.call(obj, args, ctx)) subquery = Subquery.new(ctx) # Continue with remote query execution connector.resolve( ctx, query_string(subquery), query_variables(subquery, remote_root) ) end |