Class: Graphql::Dashboard

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/graphql/dashboard.rb,
lib/graphql/dashboard/limiters.rb,
lib/graphql/dashboard/installable.rb,
lib/graphql/dashboard/subscriptions.rb,
lib/graphql/dashboard/detailed_traces.rb,
lib/graphql/dashboard/operation_store.rb,
lib/graphql/dashboard/statics_controller.rb,
lib/graphql/dashboard/landings_controller.rb,
lib/graphql/dashboard/application_controller.rb

Overview

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. Pass an array to allow selecting from multiple schemas with the schema query parameter. mount GraphQL::Dashboard, at: "graphql_dashboard", schema: ["MySchema", "OtherSchema"]

Examples:

Mounting the Dashboard in your app

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

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

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

See Also:

Defined Under Namespace

Modules: DetailedTraces, Installable, Limiters, OperationStore, Subscriptions Classes: ApplicationController, LandingsController, StaticsController