Mount the GraphiQL IDE in Ruby on Rails.
Add to your Gemfile:
gem "graphiql-rails"
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.
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