Commit 24bd017f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Load initializers after Zeitwerk takes over

This fixes the deprecation messages showing up because
we are using autoload in initializers

There is now easy way to not autoload in initializers
because we load a lot of application code there

One side-effect of this is that autoload_paths is now
frozen when running the initializers. We don't mutate
autoload_paths here anyway so this should be fine
parent 9dfd885b
......@@ -285,6 +285,13 @@ module Gitlab
g.factory_bot false
end
# This empty initializer forces the :let_zeitwerk_take_over initializer to run before we load
# initializers in config/initializers. This is done because autoloading before Zeitwerk takes
# over is deprecated but our initializers do a lot of autoloading.
# See https://gitlab.com/gitlab-org/gitlab/issues/197346 for more details
initializer :move_initializers, before: :load_config_initializers, after: :let_zeitwerk_take_over do
end
config.after_initialize do
Rails.application.reload_routes!
......
require 'gitlab/testing/request_blocker_middleware'
require 'gitlab/testing/request_inspector_middleware'
Rails.application.configure do
# Make sure the middleware is inserted first in middleware chain
config.middleware.insert_before(ActionDispatch::Static, Gitlab::Testing::RequestBlockerMiddleware)
......
......@@ -6,8 +6,6 @@ GraphQL::Field.accepts_definitions(authorize: GraphQL::Define.assign_metadata_ke
GraphQL::Schema::Object.accepts_definition(:authorize)
GraphQL::Schema::Field.accepts_definition(:authorize)
Gitlab::Application.config.after_initialize do
GitlabSchema.middleware << GraphQL::Schema::TimeoutMiddleware.new(max_seconds: Gitlab.config.gitlab.graphql_timeout) do |timeout_error, query|
Gitlab::GraphqlLogger.error(message: timeout_error.to_s, query: query.query_string, query_variables: query.provided_variables)
end
GitlabSchema.middleware << GraphQL::Schema::TimeoutMiddleware.new(max_seconds: Gitlab.config.gitlab.graphql_timeout) do |timeout_error, query|
Gitlab::GraphqlLogger.error(message: timeout_error.to_s, query: query.query_string, query_variables: query.provided_variables)
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment