Closed sarink closed 6 years ago
Update: Figured this out myself. The only thing necessary (rails 5.2.0) is to add the following lines to application.rb
require "sprockets/railtie"
config.middleware.use Rack::MethodOverride
Closing. But it might be nice to add it to the readme!
Glad you found a solution, and thanks for sharing it! Feel free to open a PR to the readme if you're interested.
If you're experiencing the error:
Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
With Rails 6/Sprockets 4, downgrade to Sprockets 3 by adding this to your Gemfile
:
gem 'sprockets', '~> 3'
And running bundle update sprockets
People starting new projects with Rails 6 in API mode will encounter issue @Li357 has pointed out. Thanks for the solution!
Thanks @Li357! gem 'sprockets', '~> 3'
worked!
For anyone getting this error, because your Rails app is API-only:
No route matches [GET] "/graphiql"
You need to temporarily update config.api_only
to be false (in application.rb
). Then you can re-run spring rails generate graphql:install
and it will generate what you need.
It also can be done manually, by adding
gem 'graphiql-rails', group: :development
to your Gemfile and
if Rails.env.development?
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"
end
to routes.rb
Thanks @Li357!
You don't need to downgrade sprocket, just add a manifest.js file and it'll work: See: https://github.com/rmosolgo/graphiql-rails/issues/13#issuecomment-640366886
FYI, if you don't want to run on a lower sprockets
version you can just do:
touch app/assets/config/manifest.js
//= link graphiql/rails/application.css
//= link graphiql/rails/application.js
Update: Figured this out myself. The only thing necessary (rails 5.2.0) is to add the following lines to
application.rb
require "sprockets/railtie" config.middleware.use Rack::MethodOverride
Closing. But it might be nice to add it to the readme!
Can you explain why you picked this?
Reading in the docs I find this for Rack::MethodOverride
Allows the method to be overridden if params[:_method] is set. This is the middleware which supports the PUT and DELETE HTTP method types.
I'm encountering this issue https://github.com/rmosolgo/graphiql-rails/issues/42 and I believe that the problem is due to using a rails 5 api only app.
Tried following these instructions https://github.com/rmosolgo/graphiql-rails/issues/13#issuecomment-256256255 but they appear to be outdated.
Is there any way to make this gem work with an API app?