Closed ababich closed 7 years ago
For those wanting to make this work on the API only rails app. Add the following to your Gemfile.
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
And un comment or add the following to your application.rb
require "sprockets/railtie"
Thanks for following up! I guess this gem depends on sprockets routing being hooked up. Feel free to PR the documentation if you can think of a way to explain that clearly.
I left out adding the assets related gems (sass-rails, uglifier, coffee-rails) to my API only Rails app (v5.1.2) & graphiql seems to work fine. 😉
@jam35L I need to serve images uploaded using Carrierwave in an API-only app, so I uncommented require "sprockets/railtie"
but it's still not working even with sass-rails, uglifier, coffee-rails gems, any ideas?
@yasser-sobhy Please clarify which part is not working. Your API only app is not working or you can't access your images?
The images wasn't working, but it's working now. Thank you
On Jul 31, 2017 7:12 AM, "James Lo" notifications@github.com wrote:
@yasser-sobhy https://github.com/yasser-sobhy Please clarify which part is not working. Your API only app is not working or you can't access your images?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rmosolgo/graphiql-rails/issues/13#issuecomment-318962997, or mute the thread https://github.com/notifications/unsubscribe-auth/AFcbhK2aMfi3NLea4tusMIOhUOZ2rJ4rks5sTVQ-gaJpZM4KPn7E .
@zfhui Did you have your rails app in api mode?
Hi. I have the same issue. I have Rails API only app. And i can't add styles with app/assets/stylesheets/application.scss. I don't see any request for css/js file even after adding gem 'sass-rails', gem 'uglifier', gem 'coffee-rails', require "sprockets/railtie" and even adding application.html.haml. rake assets:precompile creates the application...css but not request for that file comes.
The problem was that i've added application.html.haml not to app/views/layouts/ folder. Now everything is OK.
Thx @jam35L
For rails 6 create app/assets/config/manifest.js
and add
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
Just got graphiql-rails
to work with my Rails 6, API only app, and here are the steps I took:
graphiql-rails
Gemfile. It works without uglifier
, coffee-rails
and sass-rails
.
group :development do
...
gem "graphiql-rails"
end
and add to routes.rb
like in README.
if Rails.env.development?
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"
end
require "sprockets/railtie"
on top of ~config/development.rb~ config/application.rb
require "sprockets/railtie"
manifest.js
is needed. Here is the simplest version that works, based on @MITSUBOSHI changes
--- add to `app/assets/config/manifest.js`
//= link graphiql/rails/application.css
//= link graphiql/rails/application.js
And it works!
anyone managed to solve this on Rails 7 ??
anyone managed to solve this on Rails 7 ??
I created a PR for this over a year ago, but has been ignored. The fix is pretty simple. My PR has fallen out of sync with main. The maintainers should fix this ASAP as including Sprockets in Rails 7 does not work and is ill advised.
If you add GraphiQL Rails to pura Rails API app you will not get it working as assets are not accessible:
I'm pretty sure this is API-only issue, documentation how to make it working should be improved