Sha256: 2da2a55bed138e144197c8f6ee7439957e6bb966736d8ed98438412ad2437183

Contents?: true

Size: 656 Bytes

Versions: 5

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

require 'rails/generators/base'

module GraphQL
  module Generators
    class SchemaGenerator < Rails::Generators::Base # :nodoc:
      include Rails::GraphQL::BaseGenerator

      desc 'Add a new GraphQL schema'

      argument :schema, type: :string, optional: true,
        default: "#{APP_MODULE_NAME}Schema",
        desc: 'A name for the schema'

      def create_schema_file
        template 'schema.erb', "#{options[:directory]}/#{schema_name.underscore}.rb"
      end

      private

        def schema_name
          @schema_name ||= options.fetch(:schema, "#{APP_MODULE_NAME}Schema")
        end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails-graphql-1.0.2 lib/generators/graphql/schema_generator.rb
rails-graphql-1.0.1 lib/generators/graphql/schema_generator.rb
rails-graphql-1.0.0 lib/generators/graphql/schema_generator.rb
rails-graphql-1.0.0.rc2 lib/generators/graphql/schema_generator.rb
rails-graphql-1.0.0.rc1 lib/generators/graphql/schema_generator.rb