The graphiql-rails gem may produce an ‘AssetNotPrecompiled’ error while using its browser IDE.

Error

Sprockets::Rails::Helper::AssetNotPrecompiled in GraphiQL::Rails::Editors#show 

sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:372:in `raise_unless_precompiled_asset'
sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:349:in `find_debug_asset'
sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:230:in `block in lookup_debug_asset'
sprockets-rails (3.2.2) lib/sprockets/rails/helper.rb:243:in `block in resolve_asset'

Cause

This occurs because the gem includes assets that aren’t referenced in the project.

Solution

The following can be added to config/initializers/assets.rb as a potential fix:

# config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( graphiql/rails/application.js graphiql/rails/application.css ) if Rails.env.development?

[Note: The Rails server should be restarted after a configuration change.]

Credit goes to this graphiql-rails issues thread, for discussing potential solutions.