class Graphql::Dashboard

GraphQL::Dashboard is a Rails::Engine-based dashboard for viewing metadata about your GraphQL schema.

Pass the class name of your schema when mounting it. See GraphQL::Tracing::DetailedTrace DetailedTrace for viewing production traces in the Dashboard

Examples

Example: Mounting the Dashboard in your app

mount GraphQL::Dashboard, at: "graphql_dashboard", schema: "MySchema"

To allow selecting from multiple schemas with the schema query parameter:

mount GraphQL::Dashboard, at: "graphql_dashboard", schema: ["MySchema", "OtherSchema"]

Example: Authenticating the Dashboard with HTTP Basic Auth

# config/initializers/graphql_dashboard.rb
GraphQL::Dashboard.middleware.use(Rack::Auth::Basic) do |username, password|
  # Compare the provided username/password to an application setting:
  ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.graphql_dashboard_username, username) &&
    ActiveSupport::SecurityUtils.secure_compare(Rails.application.credentials.graphql_dashboard_username, password)
end

Example: Custom Rails authentication

# config/initializers/graphql_dashboard.rb
ActiveSupport.on_load(:graphql_dashboard_application_controller) do
  # context here is GraphQL::Dashboard::ApplicationController

  before_action do
    raise ActionController::RoutingError.new('Not Found') unless current_user&.admin?
  end

  def current_user
    # load current user
  end
end