Skip to content

Commit

Permalink
Add docs for sprockets or propshaft
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Feb 23, 2024
1 parent 350543e commit 9f50358
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Mount the [GraphiQL IDE](https://github.com/graphql/graphiql) in Ruby on Rails.
Add to your Gemfile:

```ruby
gem "graphiql-rails"
bundle add graphiql-rails
```

Additionally, you'll need [Sprockets or Propshaft](#sprockets-or-propshaft) to serve the JS and CSS assets.

## Usage

### Mount the Engine
Expand All @@ -31,9 +33,19 @@ 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.

#### Note on API Mode
### Sprockets or Propshaft

You'll need [Sprockets](https://github.com/rails/sprockets) or [Propshaft](https://github.com/rails/propshaft) to deliver the JS and CSS for GraphiQL. If you don't already have one of those, you can add them with:

```sh
$ bundle add sprockets-rails
# or
$ bundle add propshaft
```

If you're using Rails 6 in "API mode", you'll also need to do the following:
#### API Mode

If you're using Rails 6+ in "API mode", you'll also need to do the following:

1. Add `require "sprockets/railtie"` to your `application.rb`.

Expand All @@ -45,13 +57,14 @@ If you're using Rails 6 in "API mode", you'll also need to do the following:
```

Additionally, for Rails 6, you'll also need to add `dartsass-sprockets` gem to your Gemfile and add a `manifest.js` file for Sprockets 4 to work:

```
--- add to `app/assets/config/manifest.js`
//= link graphiql/rails/application.css
//= link graphiql/rails/application.js
```
Note that the `sassc-rails` gem is unmaintained and [breaks with the newer GraphiQL](https://github.com/rmosolgo/graphiql-rails/issues/106).
See more details in [issue #13](https://github.com/rmosolgo/graphiql-rails/issues/13#issuecomment-640366886)

Note that the `sassc-rails` gem is unmaintained and [breaks with the newer GraphiQL](https://github.com/rmosolgo/graphiql-rails/issues/106). See more details in [issue #13](https://github.com/rmosolgo/graphiql-rails/issues/13#issuecomment-640366886)

### Configuration

Expand Down

0 comments on commit 9f50358

Please sign in to comment.