Skip to content

Fix module and path of generated BaseResolver #4755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/generators/graphql/install_generator.rb
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ def create_folder_structure
end

# All resolvers are defined as living in their own module, including this class.
template("base_resolver.erb", "#{options[:directory]}/resolvers/base.rb")
template("base_resolver.erb", "#{options[:directory]}/resolvers/base_resolver.rb")

# Note: You can't have a schema without the query type, otherwise introspection breaks
template("query_type.erb", "#{options[:directory]}/types/query_type.rb")
2 changes: 1 addition & 1 deletion lib/generators/graphql/templates/base_resolver.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% module_namespacing_when_supported do -%>
module Types
module Resolvers
class BaseResolver < GraphQL::Schema::Resolver
end
end
Original file line number Diff line number Diff line change
@@ -40,6 +40,11 @@ def refute_file(path)
assert_includes contents, expected_graphiql_route
end

assert_file "app/graphql/resolvers/base_resolver.rb" do |contents|
assert_includes contents, "module Resolvers"
assert_includes contents, "class BaseResolver < GraphQL::Schema::Resolver"
end

assert_file "Gemfile" do |contents|
assert_match %r{gem ('|")graphiql-rails('|"), :?group(:| =>) :development}, contents
end