lib/generators/graphql/install_generator.rb in graphql-1.10.5 vs lib/generators/graphql/install_generator.rb in graphql-1.10.6
- old
+ new
@@ -85,10 +85,15 @@
class_option :batch,
type: :boolean,
default: false,
desc: "Include GraphQL::Batch installation"
+ class_option :playground,
+ type: :boolean,
+ default: false,
+ desc: "Use GraphQL Playground over Graphiql as IDE"
+
# These two options are taken from Rails' own generators'
class_option :api,
type: :boolean,
desc: "Preconfigure smaller stack for API only apps"
@@ -136,9 +141,31 @@
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"
end
RUBY
end
end
+ end
+
+ if options[:playground]
+ gem("graphql_playground-rails", group: :development)
+
+ log :route, 'graphql_playground-rails'
+ shell.mute do
+ if Rails::VERSION::STRING > "5.2"
+ route <<-RUBY
+if Rails.env.development?
+ mount GraphqlPlayground::Rails::Engine, at: "/playground", graphql_path: "/graphql"
+end
+RUBY
+ else
+ route <<-RUBY
+if Rails.env.development?
+ mount GraphqlPlayground::Rails::Engine, at: "/playground", graphql_path: "/graphql"
+ end
+RUBY
+ end
+ end
+
end
if gemfile_modified?
say "Gemfile has been modified, make sure you `bundle install`"
end