class GraphQLPlayground

Constants

CDN_URL

Public Class Methods

new(app = nil, cdn_url: CDN_URL, version: '', endpoint: '/') click to toggle source

Initialize the middleware

@param string cdn_url The CDN url for graphql playground (defaults to the official release) @param string version The version of the graphql playground to use (defaults to latest) @param string endpoint The endpoint of your graphql server

# File lib/graphql_playground.rb, line 11
def initialize(app = nil, cdn_url: CDN_URL, version: '', endpoint: '/')
  @app = app
  @cdn_url = cdn_url
  @version = version
  @endpoint = endpoint
  @index_template = File.read(template('index.html.erb'))
end

Public Instance Methods

call(env) click to toggle source
# File lib/graphql_playground.rb, line 23
def call(env)
  ['200', {'Content-Type' => 'text/html'}, [ERB.new(@index_template).result(binding)]]
end
template(path) click to toggle source
# File lib/graphql_playground.rb, line 19
def template(path)
  File.expand_path("templates/#{path}", __dir__)
end