Mount the GraphiQL IDE in Ruby on Rails.

Add to your Gemfile:
bundle add 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.config values in an initializer (eg, config/initializers/graphiql.rb). The configs are:
query_params (boolean, default false): if true, the GraphQL query string will be persisted the page's query paramsinitial_query (string, default nil): if provided, it will be rendered in the query pane for a visitor's first visittitle (string, default nil): if provided, it will be rendered in the page taglogo (string, default nil): if provided, it will be the text logocsrf (boolean, default true): include X-CSRF-Token in GraphiQL's HTTP requestsheader_editor_enabled (boolean, default false): if provided, the header editor will be renderedheaders (hash, String => Proc): procs to fetch header values for GraphiQL's HTTP requests, in the form (view_context) -> { ... }. For example:
ruby
GraphiQL::Rails.config.headers['Authorization'] = -> (context) { "bearer #{context.cookies['_graphql_token']}" }
input_value_deprecation (boolean, default false): if provided, the deprecated arguments will be rendered
should_persist_headers (boolean, default nil): if true, the headers in the editor will be persisted. If false, the toggle for 'Persist headers' will not be shown in the settingsrake testyarn run build| 日期 | 榜单 | 排名 | 周期新增 | 总 STAR |
|---|