Sha256: 94aa9507f6d78dd09499cd44bc5cb6a031db8c60a857cdd40567a4f844fbbae2

Contents?: true

Size: 681 Bytes

Versions: 108

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true
require 'generators/graphql/type_generator'

module Graphql
  module Generators
    # Generate an enum type by name, with the given values.
    # To add a `value:` option, add another value after a `:`.
    #
    # ```
    # rails g graphql:enum ProgrammingLanguage RUBY PYTHON PERL PERL6:"PERL"
    # ```
    class EnumGenerator < TypeGeneratorBase
      desc "Create a GraphQL::EnumType with the given name and values"
      source_root File.expand_path('../templates', __FILE__)

      private

      def graphql_type
        "enum"
      end

      def prepared_values
        custom_fields.map { |v| v.split(":", 2) }
      end
    end
  end
end

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
graphql-2.4.9 lib/generators/graphql/enum_generator.rb
graphql-2.4.8 lib/generators/graphql/enum_generator.rb
graphql-2.4.7 lib/generators/graphql/enum_generator.rb
graphql-2.4.6 lib/generators/graphql/enum_generator.rb
graphql-2.4.5 lib/generators/graphql/enum_generator.rb
graphql-2.4.4 lib/generators/graphql/enum_generator.rb
graphql-2.4.3 lib/generators/graphql/enum_generator.rb
graphql-2.4.2 lib/generators/graphql/enum_generator.rb
graphql-2.4.1 lib/generators/graphql/enum_generator.rb
graphql-2.4.0 lib/generators/graphql/enum_generator.rb
graphql-2.3.20 lib/generators/graphql/enum_generator.rb
graphql-2.3.19 lib/generators/graphql/enum_generator.rb
graphql-2.3.18 lib/generators/graphql/enum_generator.rb
graphql-2.3.17 lib/generators/graphql/enum_generator.rb
graphql-2.3.16 lib/generators/graphql/enum_generator.rb
graphql-2.3.15 lib/generators/graphql/enum_generator.rb
graphql-2.3.14 lib/generators/graphql/enum_generator.rb
graphql-2.3.13 lib/generators/graphql/enum_generator.rb
graphql-2.3.12 lib/generators/graphql/enum_generator.rb
graphql-2.3.11 lib/generators/graphql/enum_generator.rb