lib/okay/graphql.rb in okay-11.0.0 vs lib/okay/graphql.rb in okay-12.0.0
- old
+ new
@@ -15,11 +15,13 @@
# query = GraphQL.query {
# viewer {
# login
# }
# }
- # response = request.submit!(:github, {bearer_token: ENV["DEMO_GITHUB_TOKEN"]})
+ #
+ # token = ENV["DEMO_GITHUB_TOKEN"]
+ # response = request.submit!(:github, {bearer_token: token})
# pp JSON.parse(response.body)
class GraphQL
Container = Struct.new(:value) do
def inspect
value
@@ -34,10 +36,11 @@
@indent = indent
@indent_str = " " * indent
instance_exec(&query)
end
+ # rubocop:disable Metrics/AbcSize
def method_missing(name, *args, **kwargs, &block)
query_part = @indent_str + name.to_s
if !args.empty? || !kwargs.empty?
query_part += "("
@@ -57,9 +60,10 @@
query_part += @indent_str + "}"
end
@query += "#{query_part}\n"
end
+ # rubocop:enable Metrics/AbcSize
def to_s
@query
end
end