Module: Graphtown::QueryBuilder
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/graphtown/query_builder.rb
Defined Under Namespace
Classes: Queries
Instance Method Summary collapse
-
#configure_graphql_client(client) ⇒ Object
override in concrete class if need be.
- #graphql_client ⇒ Object
-
#graphql_endpoint ⇒ Object
override in concrete class if need be.
- #queries ⇒ Object
Instance Method Details
#configure_graphql_client(client) ⇒ Object
override in concrete class if need be
58 |
# File 'lib/graphtown/query_builder.rb', line 58 def configure_graphql_client(client); end |
#graphql_client ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/graphtown/query_builder.rb', line 42 def graphql_client raise "Please add graphql_endpoint to your config file" unless config[:graphql_endpoint] Graphlient::Client.new(graphql_endpoint) do |client| configure_graphql_client(client) end end |
#graphql_endpoint ⇒ Object
override in concrete class if need be
51 52 53 54 55 |
# File 'lib/graphtown/query_builder.rb', line 51 def graphql_endpoint raise "Please add graphql_endpoint to your config file" unless config[:graphql_endpoint] config[:graphql_endpoint] end |
#queries ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/graphtown/query_builder.rb', line 21 def queries return self.class.graphql_queries if @_executed_queries client = graphql_client self.class.graphql_queries.each_pair do |graph_name, block| graph_dsl = Graphlient::Query.new(&block) query_variables = if respond_to?("variables_for_#{graph_name}") send("variables_for_#{graph_name}") end self.class.graphql_queries.send( "#{graph_name}=", client.execute(graph_dsl.to_s, query_variables).data.send(graph_name) ) end @_executed_queries = true self.class.graphql_queries end |