class GraphqlPlayground::Rails::Config
Constants
- CSRF_TOKEN_HEADER
- DEFAULT_HEADERS
- DEFAULT_SETTINGS
Attributes
csrf[RW]
headers[RW]
@example Adding a header to the request
config.headers["My-Header"] = -> (view_context) { "My-Value" }
@return [Hash<String => Proc>] Keys are headers to include in GraphQL requests, values are `->(view_context) { … }` procs to determin values
logo[RW]
playground_css_url[RW]
playground_js_url[RW]
playground_version[RW]
settings[RW]
title[RW]
Public Class Methods
new()
click to toggle source
# File lib/graphql_playground/rails/config.rb, line 24 def initialize() @title = nil @favicon = nil @csrf = true @headers = DEFAULT_HEADERS @playground_version = 'latest' @playground_js_url = nil @playground_css_url = nil @settings = {} end
Public Instance Methods
all_settings()
click to toggle source
# File lib/graphql_playground/rails/config.rb, line 48 def all_settings DEFAULT_SETTINGS.merge(settings) end
resolve_headers(view_context)
click to toggle source
Call defined procs, add CSRF token if specified
# File lib/graphql_playground/rails/config.rb, line 36 def resolve_headers(view_context) all_headers = DEFAULT_HEADERS.merge(headers) if csrf all_headers = all_headers.merge(CSRF_TOKEN_HEADER) end all_headers.each_with_object({}) do |(key, value), memo| memo[key] = value.call(view_context) end end