Class: Giraph::Subquery

Inherits:
Object
  • Object
show all
Defined in:
lib/giraph/subquery.rb

Overview

Defines a thin & sane API for the sub-query extraction from the context provided to resolvers via AST, graphql-ruby API and a touch of regex.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Subquery

Returns a new instance of Subquery.



8
9
10
11
12
13
# File 'lib/giraph/subquery.rb', line 8

def initialize(context)
  @context = context

  @query = context.query
  @query_string = context.ast_node.to_query_string
end

Instance Attribute Details

#queryObject (readonly)

Returns the value of attribute query.



6
7
8
# File 'lib/giraph/subquery.rb', line 6

def query
  @query
end

#query_stringObject (readonly)

Returns the value of attribute query_string.



6
7
8
# File 'lib/giraph/subquery.rb', line 6

def query_string
  @query_string
end

Instance Method Details

#subquery_stringObject



15
16
17
# File 'lib/giraph/subquery.rb', line 15

def subquery_string
  "GiraphQuery #{query_variables} #{query_selections}"
end

#variable_stringObject



19
20
21
22
23
24
# File 'lib/giraph/subquery.rb', line 19

def variable_string
  dict = variable_assignments
  dict = yield dict if block_given?

  dict.to_json
end