Skip to content

Zeitwerk Rails 6 - autoloading warnings #2456

@srgoldman

Description

@srgoldman

Adding the graphql-errors gem and this initializer:

GraphQL::Errors.configure(BlogSchema) do
  rescue_from GraphQL::UnauthorizedError do |e|
    GraphQL::ExecutionError.new e.message
  end
end

to the sample blog app (fresh Rails 6 app) results in the following error when running specs:

$ rails spec
/Users/sethgoldman/.rbenv/versions/2.6.3/bin/ruby -I/Users/sethgoldman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rspec-core-3.8.2/lib:/Users/sethgoldman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rspec-support-3.8.2/lib /Users/sethgoldman/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/rspec-core-3.8.2/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
DEPRECATION WARNING: Initialization autoloaded the constants Types, Types::BaseObject, Types::MutationType, Types::User, Types::QueryType, and BlogSchema.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload Types, for example,
the expected changes won't be reflected in that stale Module object.

These autoloaded constants have been unloaded.

Please, check the "Autoloading and Reloading Constants" guide for solutions.
 (called from <top (required)> at /Users/sethgoldman/Code/blog/config/environment.rb:5)
..*

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) User add some examples to (or delete) /Users/sethgoldman/Code/blog/spec/models/user_spec.rb
     # Not yet implemented
     # ./spec/models/user_spec.rb:4


Finished in 0.017 seconds (files took 1.12 seconds to load)
3 examples, 0 failures, 1 pending

I've uploaded the code here: https://github.com/srgoldman/rails6_blog_issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions