Skip to content

env-forks/graphiql-rails

 
 

Repository files navigation

Graphiql-Rails Gem Version Build Status

Mount the Graphiql IDE in Ruby on Rails.

image

Installation

Add to your Gemfile:

gem "graphiql-rails"

Usage

Mount the Engine

Add the engine to routes.rb:

# config/routes.rb
Rails.application.routes.draw do
  # ...
  if Rails.env.development?
    mount Graphiql::Rails::Engine, at: "/graphiql", graphql_path: "/your/endpoint"
  end
end
  • at: is the path where Graphiql will be served. You can access Graphiql by visiting that path in your app.
  • graphql_path: is the path to the GraphQL endpoint. Graphiql will send queries to this path.

Configuration

You can override Graphiql::Rails configs in an initializer (eg, config/initializers/graphiql.rb). The configs are:

# These are the default values:
Graphiql::Rails.config.query_params = false # if true, the GraphQL query string will be persisted the page's query params.
Graphiql::Rails.config.initial_query = Graphiql::Rails::WELCOME_MESSAGE # This string is presented to a new user
Graphiql::Rails.config.csrf = false # if true, CSRF token will added and sent along with POST request to the GraphQL endpoint

To-do

  • Automate the update process for Graphiql assets

About

Mount the GrapiQL query editor in a Rails app

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 97.3%
  • CSS 1.7%
  • Other 1.0%