class Okay::GraphQL::QueryDSL
Implements the GraphQL
DSL.
Public Class Methods
new(indent = 0, &query)
click to toggle source
# File lib/okay/graphql.rb, line 34 def initialize(indent = 0, &query) @query = "" @indent = indent @indent_str = " " * indent instance_exec(&query) end
Public Instance Methods
method_missing(name, *args, **kwargs, &block)
click to toggle source
rubocop:disable Metrics/AbcSize
# File lib/okay/graphql.rb, line 42 def method_missing(name, *args, **kwargs, &block) query_part = @indent_str + name.to_s if !args.empty? || !kwargs.empty? query_part += "(" query_args = [] query_args += args unless args.empty? query_args += kwargs.map { |k, v| [k, v.inspect].join(": ") } query_part += query_args.join(", ") query_part += ")" end if block query_part += " {\n" query_part += QueryDSL.new(@indent + 2, &block).to_s query_part += @indent_str + "}" end @query += "#{query_part}\n" end
to_s()
click to toggle source
rubocop:enable Metrics/AbcSize
# File lib/okay/graphql.rb, line 67 def to_s @query end