Skip to content

Commit 6deb2d9

Browse files
committed
Lazily define engine routes using routes do ... end
1 parent 6f21595 commit 6deb2d9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/graphql.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ class << self
126126
autoload :Testing, "graphql/testing"
127127
autoload :Current, "graphql/current"
128128
if defined?(::Rails::Engine)
129-
autoload :Dashboard, 'graphql/dashboard'
129+
# This needs to be defined before Rails runs `add_routing_paths`,
130+
# otherwise GraphQL::Dashboard's routes won't have been gathered for loading
131+
# when that initializer runs.
132+
require 'graphql/dashboard'
130133
end
131134
end
132135

lib/graphql/dashboard.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module Graphql
3434
class Dashboard < Rails::Engine
3535
engine_name "graphql_dashboard"
3636
isolate_namespace(Graphql::Dashboard)
37-
routes.draw do
37+
routes do
3838
root "landings#show"
3939
resources :statics, only: :show, constraints: { id: /[0-9A-Za-z\-.]+/ }
4040

0 commit comments

Comments
 (0)