class Graphql::Generators::InstallGenerator

Use ‘–no-graphiql` to skip `graphiql-rails` installation.
Accept a `–batch` option which adds `GraphQL::Batch` setup.
The root `node(id: ID!)` field.
Accept a `–relay` option which adds
“`
post “/graphql”, to: “graphql#execute”
# config/routes.rb
“`ruby
Add a route for that controller:
“`
app/controllers/graphql_controller.rb
“`
Add a controller for serving GraphQL queries:
(Add `.gitkeep`s by default, support `–skip-keeps`)
“`
- {app_name}_schema.rb
- mutations/
- loaders/
- query_type.rb
- types/
- resolvers/
- graphql/
- app/
“`
Setup a folder structure for GraphQL:
Add GraphQL to a Rails app with `rails g graphql:install`.

def create_dir(dir)

def create_dir(dir)
  empty_directory(dir)
  if !options[:skip_keeps]
    create_file("#{dir}/.keep")
  end
end

def create_folder_structure

def create_folder_structure
  create_dir("app/graphql/mutations")
  create_dir("app/graphql/types")
  template("query_type.erb", "app/graphql/types/query_type.rb")
  template("schema.erb", "app/graphql/#{schema_name.underscore}.rb")
  template("graphql_controller.erb", "app/controllers/graphql_controller.rb")
  route('post "/graphql", to: "graphql#execute"')
  if !options[:skip_graphiql]
    gem("graphiql-rails", group: :development)
    route(GRAPHIQL_ROUTE)
  end
  if options[:batch]
    gem("graphql-batch")
    create_dir("app/graphql/loaders")
  end
end

def schema_name

def schema_name
  @schema_name ||= begin
    if options[:schema]
      options[:schema]
    else
      require File.expand_path("config/application", destination_root)
      "#{Rails.application.class.parent_name}Schema"
    end
  end
end