class Rack::GraphiQL

Constants

FETCH_VERSION
GRAPHIQL_VERSION
REACT_DOM_VERSION
REACT_VERSION
VERSION

Public Class Methods

new(endpoint:) click to toggle source
# File lib/rack/graphiql.rb, line 14
def initialize(endpoint:)
  @endpoint = endpoint
  @template = ERB.new(open(__FILE__).read.split("__END__\n").last)
end

Public Instance Methods

call(env) click to toggle source
# File lib/rack/graphiql.rb, line 19
def call(env)
  req = Rack::Request.new(env)
  graphiql_query = req.params['query']
  graphiql_variables = begin
                         JSON.pretty_generate(JSON.parse(req.params['variables'] || ''))
                       rescue JSON::ParserError
                         ''
                       end
  graphiql_operation_name = req.params['operationName']
  [200, {'Content-Type' => 'text/html'}, [@template.result(binding)]]
end

Private Instance Methods

endpoint() click to toggle source
# File lib/rack/graphiql.rb, line 33
def endpoint
  @endpoint
end
fetch_version() click to toggle source
# File lib/rack/graphiql.rb, line 41
def fetch_version
  FETCH_VERSION
end
graphiql_version() click to toggle source
# File lib/rack/graphiql.rb, line 37
def graphiql_version
  GRAPHIQL_VERSION
end
react_dom_version() click to toggle source
# File lib/rack/graphiql.rb, line 49
def react_dom_version
  REACT_DOM_VERSION
end
react_version() click to toggle source
# File lib/rack/graphiql.rb, line 45
def react_version
  REACT_VERSION
end