rmosolgo / graphiql-rails

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

uninitialized constant GraphiQL (NameError) #117

Open y-okamoto-1113 opened 6 months ago

y-okamoto-1113 commented 6 months ago

thank you for maintaining this gem. i need your help 😄

uninitialized constant GraphiQL (NameError) occurs when i execute rails s. error log is below.

/app/config/routes.rb:5:in `block in <main>': uninitialized constant GraphiQL (NameError)

    mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"
          ^^^^^^^^
Did you mean?  GraphQL
        from /usr/local/bundle/ruby/3.3.0/gems/actionpack-7.1.3.2/lib/action_dispatch/routing/route_set.rb:448:in `instance_exec'
        from /usr/local/bundle/ruby/3.3.0/gems/actionpack-7.1.3.2/lib/action_dispatch/routing/route_set.rb:448:in `eval_block'
        from /usr/local/bundle/ruby/3.3.0/gems/actionpack-7.1.3.2/lib/action_dispatch/routing/route_set.rb:430:in `draw'
        from /app/config/routes.rb:1:in `<main>'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/routes_reloader.rb:50:in `load'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/routes_reloader.rb:50:in `block in load_paths'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/routes_reloader.rb:50:in `each'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/routes_reloader.rb:50:in `load_paths'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/routes_reloader.rb:24:in `reload!'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/routes_reloader.rb:38:in `block in updater'
        from /usr/local/bundle/ruby/3.3.0/gems/activesupport-7.1.3.2/lib/active_support/file_update_checker.rb:85:in `execute'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/routes_reloader.rb:13:in `execute'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application/finisher.rb:161:in `block in <module:Finisher>'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:32:in `instance_exec'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:32:in `run'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:231:in `block in tsort_each'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:353:in `block (2 levels) in each_strongly_connected_component'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:434:in `each_strongly_connected_component_from'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:352:in `block in each_strongly_connected_component'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:350:in `each'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:350:in `call'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:350:in `each_strongly_connected_component'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:229:in `tsort_each'
        from /usr/local/lib/ruby/3.3.0/tsort.rb:208:in `tsort_each'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/initializable.rb:60:in `run_initializers'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/application.rb:426:in `initialize!'
        from /app/config/environment.rb:5:in `<main>'
        from config.ru:3:in `require_relative'
        from config.ru:3:in `block in <main>'
        from /usr/local/bundle/ruby/3.3.0/gems/rack-3.0.10/lib/rack/builder.rb:103:in `eval'
        from /usr/local/bundle/ruby/3.3.0/gems/rack-3.0.10/lib/rack/builder.rb:103:in `new_from_string'
        from /usr/local/bundle/ruby/3.3.0/gems/rack-3.0.10/lib/rack/builder.rb:94:in `load_file'
        from /usr/local/bundle/ruby/3.3.0/gems/rack-3.0.10/lib/rack/builder.rb:64:in `parse_file'
        from /usr/local/bundle/ruby/3.3.0/gems/rackup-2.1.0/lib/rackup/server.rb:354:in `build_app_and_options_from_config'
        from /usr/local/bundle/ruby/3.3.0/gems/rackup-2.1.0/lib/rackup/server.rb:263:in `app'
        from /usr/local/bundle/ruby/3.3.0/gems/rackup-2.1.0/lib/rackup/server.rb:424:in `wrapped_app'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/commands/server/server_command.rb:76:in `log_to_stdout'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/commands/server/server_command.rb:36:in `start'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/commands/server/server_command.rb:145:in `block in perform'
        from <internal:kernel>:90:in `tap'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/commands/server/server_command.rb:136:in `perform'
        from /usr/local/bundle/ruby/3.3.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
        from /usr/local/bundle/ruby/3.3.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/command/base.rb:178:in `invoke_command'
        from /usr/local/bundle/ruby/3.3.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/command/base.rb:73:in `perform'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/command.rb:71:in `block in invoke'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/command.rb:149:in `with_argv'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/command.rb:69:in `invoke'
        from /usr/local/bundle/ruby/3.3.0/gems/railties-7.1.3.2/lib/rails/commands.rb:18:in `<main>'
        from /usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `require'
        from /usr/local/lib/ruby/3.3.0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
        from /usr/local/bundle/ruby/3.3.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from bin/rails:4:in `<main>'

my config/routes.rb is below.

if Rails.env.development?
  mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"
end

please help me 🥺

rmosolgo commented 6 months ago

Hi! Sorry for the trouble. Is graphiql-rails in your gemfile? Could you please share the line from your gemfile that includes it?

you could try adding require "graphiql-rails" to the top of the problem file to see if that fixes the problem.