Skip to content

Commit 6b2f72f

Browse files
author
Robert Mosolgo
authored
Merge pull request #3441 from rmosolgo/generator-fixes
Don't re-add graphiql-rails when installed twice
2 parents fcc8aca + 43e4b13 commit 6b2f72f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/generators/graphql/install_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def create_folder_structure
122122
if options.api?
123123
say("Skipped graphiql, as this rails project is API only")
124124
say(" You may wish to use GraphiQL.app for development: https://github.com/skevy/graphiql-app")
125-
elsif !options[:skip_graphiql]
125+
elsif !options[:skip_graphiql] && !File.read(Rails.root.join("Gemfile")).include?("graphiql-rails")
126126
gem("graphiql-rails", group: :development)
127127

128128
# This is a little cheat just to get cleaner shell output:

spec/integration/rails/generators/graphql/install_generator_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ module BaseInterface
121121
end
122122
RUBY
123123
assert_file "app/graphql/types/base_interface.rb", expected_base_interface
124+
125+
# Run it again and make sure the gemfile only contains graphiql-rails once
126+
FileUtils.cd(File.join(destination_root)) do
127+
`rails g graphql:install --relay false`
128+
end
129+
assert_file "Gemfile" do |contents|
130+
assert_equal 1, contents.scan(/graphiql-rails/).length
131+
end
124132
end
125133

126134
test "it allows for a user-specified install directory" do

0 commit comments

Comments
 (0)