Class: Boring::Graphql::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Boring::Graphql::InstallGenerator
- Defined in:
- lib/generators/boring/graphql/install/install_generator.rb
Constant Summary collapse
- OPTIONS =
%w(relay batch playground no-graphiql schema)
Instance Method Summary collapse
Instance Method Details
#add_graphql_gem ⇒ Object
14 15 16 17 18 19 |
# File 'lib/generators/boring/graphql/install/install_generator.rb', line 14 def add_graphql_gem say "Adding graphql gem", :green Bundler.with_unbundled_env do run "bundle add graphql" end end |
#adds_graphql_resolver ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/generators/boring/graphql/install/install_generator.rb', line 35 def adds_graphql_resolver return if [:skip_resolver_setup] template("base_resolver.rb", "app/graphql/resolvers/base_resolver.rb") template("hello_world_resolver.rb", "app/graphql/resolvers/hello_world_resolver.rb") insert_into_file "app/graphql/types/query_type.rb", <<~RUBY, after: /class QueryType < Types::BaseObject\n/ \t\t# TODO: remove me \t\tfield :hello, resolver: Resolvers::HelloWorldResolver RUBY end |
#run_graphql_generator ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/generators/boring/graphql/install/install_generator.rb', line 21 def run_graphql_generator say "Running GraphQL default generator", :green run "bundle exec rails generate graphql:install" run "bundle install" graphiql_precompile_assets = <<~RUBY \n if Rails.env.development? Rails.application.config.assets.precompile += %w[graphiql/rails/application.js graphiql/rails/application.css] end RUBY append_to_file "config/initializers/assets.rb", graphiql_precompile_assets end |