My error:
/Users/-/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:512:in `load_missing_constant':
Unable to autoload constant Types::QueryType, expected /Users/-/project/app/graph/types/query_type.rb to define it (LoadError)
app/graph/schema.rb:
module Graph
Schema = GraphQL::Schema.define do
query Types::QueryType
end
end
app/graph/types/query_type.rb:
module Graph
module Types
QueryType = GraphQL::ObjectType.define do
name 'Query'
end
end
end
config/application.rb:
config.autoload_paths << "#{Rails.root}/app/graph"
config.autoload_paths << "#{Rails.root}/app/graph/interfaces"
config.autoload_paths << "#{Rails.root}/app/graph/types"
config.autoload_paths << "#{Rails.root}/app/graph/unions"
Rails correctly expects Types::QueryType
to be defined in app/graph/types/query_type.rb
, however - weirdly enough - somehow concludes that file does not define Types::QueryType
, which it clearly does.
Even weirder: when jumping into a console, it only throws this error the first time Types::QueryType
is requested. The second time however Types::QueryType
resolves to the correct definition.
I'm probably doing something wrong here, but I just can't seem to find it.
Aucun commentaire:
Enregistrer un commentaire