rmosolgo / graphiql-rails

Mount the GraphiQL query editor in a Rails app
MIT License
447 stars 137 forks source link

Route could not be found for application.css / application.js #30

Open Mori opened 7 years ago

Mori commented 7 years ago

This issue looks like a zombie of #13 (Assets are not accessible in API-only app), which was closed a year ago. I followed the advice of jam35L in that issue with no effect. Here is the log output:

Started GET "/graphiql/admin" for 10.242.2.16 at 2017-10-24 13:40:33 -0400                                                              
Processing by GraphiQL::Rails::EditorsController#show as HTML                                                                           
  Parameters: {"graphql_path"=>"/queries/admin"}                                                                                        
  Rendered /nhome/kkaplan/.rbenv/versions/2.1.7/lib/ruby/gems/2.1.0/gems/graphiql-rails-1.4.5/app/views/graphiql/rails/editors/show.html.erb (5.9ms)                                                                                                                            
Completed 200 OK in 25.0ms (Views: 24.6ms | ActiveRecord: 0.0ms)                                                                        

Started GET "/stylesheets/graphiql/rails/application.css" for 10.242.2.16 at 2017-10-24 13:40:34 -0400                                  
Processing by ApplicationController#routing_error as CSS                                                                                
  Parameters: {"path"=>"stylesheets/graphiql/rails/application"}                                                                        
Route could not be found for GET /stylesheets/graphiql/rails/application.css                                                            
Completed 404 Not Found in 0.5ms (ActiveRecord: 0.0ms)                                                                                  

Started GET "/javascripts/graphiql/rails/application.js" for 10.242.2.16 at 2017-10-24 13:40:34 -0400                                   
Processing by ApplicationController#routing_error as JS                                                                                 
  Parameters: {"path"=>"javascripts/graphiql/rails/application"}                                                                        
Route could not be found for GET /javascripts/graphiql/rails/application.js                                                             
Completed 404 Not Found in 0.2ms (ActiveRecord: 0.0ms)      

I tried running rake assets:precompile, and also tried copying the app/assets/ folder into my Rails app and then running rake assets:precompile. These didn't have an effect. I also tried copying the javascripts/ and stylesheets folders into my app's public/ folder. This prevents the Route could not be found error, but the page never loads. Should I try moving the whole engine into my app?

I'm constrained to use Rails 3.2 in this app, is that a known problem? I do have a minimal working graphql endpoint at /queries/admin, tested with curl. Any suggestions beyond those in issue #13?

Thanks!

borakilicoglu commented 6 years ago

i had a same issue!

ActionController::RoutingError (No route matches [GET] "/javascripts/graphiql/rails/application.js"):

alphabt commented 5 years ago

Same with Rails 6.0.0.rc1

$ rails s
=> Booting Puma
=> Rails 6.0.0.rc1 application starting in development
=> Run `rails server --help` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/graphiql" for ::1 at 2019-06-05 13:52:00 +0800
   (41.7ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by GraphiQL::Rails::EditorsController#show as HTML
  Parameters: {"graphql_path"=>"/graphql"}
  Rendering /Users/<snipped>/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/graphiql-rails-1.7.0/app/views/graphiql/rails/editors/show.html.erb
  Rendered /Users/<snipped>/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/graphiql-rails-1.7.0/app/views/graphiql/rails/editors/show.html.erb (Duration: 28.6ms | Allocations: 852)
Completed 200 OK in 44ms (Views: 38.1ms | ActiveRecord: 0.0ms | Allocations: 2572)

Started GET "/stylesheets/graphiql/rails/application.css" for ::1 at 2019-06-05 13:52:00 +0800
Started GET "/javascripts/graphiql/rails/application.js" for ::1 at 2019-06-05 13:52:00 +0800

ActionController::RoutingError (No route matches [GET] "/stylesheets/graphiql/rails/application.css"):

EDIT: My issue was I had require 'sprockets/railtie' commented out in config/application.rb. Uncommenting it fixed the issue for me.

htmlboss commented 2 years ago

Same issue with Rails 7.0.2, but the solution @alphabt suggested fix it for me.

suyogtaksande commented 2 years ago

@htmlboss please check this link, following the steps mentioned here solved my problem.