Giter Club home page Giter Club logo

graphiql-rails's Introduction

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.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 params

  • initial_query (string, default nil): if provided, it will be rendered in the query pane for a visitor's first visit

  • csrf (boolean, default true): include X-CSRF-Token in GraphiQL's HTTP requests

  • headers (hash, String => Proc): procs to fetch header values for GraphiQL's HTTP requests, in the form (view_context) -> { ... }. For example:

    GraphiQL::Rails.config.headers['Authorization'] = -> (context) { "bearer #{context.cookies['_graphql_token']}" }

Development

  • Tests: rake test
  • Update GraphiQL & dependencies: rake update_graphiql

graphiql-rails's People

Contributors

andrewraycode avatar armstrjare avatar dschwar avatar exaspark avatar gfx avatar irminsul avatar maxpower15 avatar mikelspohn avatar mynameisrufus avatar rmosolgo avatar sjchmiela avatar theorygeek avatar tiegz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.