Sha256: 981be7681136ace394039752f6afc16f7e7d569fbc12316d989abc7285160a01

Contents?: true

Size: 945 Bytes

Versions: 81

Compression:

Stored size: 945 Bytes

Contents

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

module Graphql
  module Generators
    # Generate an object type by name,
    # with the specified fields.
    #
    # ```
    # rails g graphql:object PostType name:String!
    # ```
    #
    # Add the Node interface with `--node`.
    class ObjectGenerator < TypeGeneratorBase
      desc "Create a GraphQL::ObjectType with the given name and fields"
      source_root File.expand_path('../templates', __FILE__)

      argument :fields,
        type: :array,
        default: [],
        banner: "name:type name:type ...",
        desc: "Fields for this object (type may be expressed as Ruby or GraphQL)"

      class_option :node,
        type: :boolean,
        default: false,
        desc: "Include the Relay Node interface"

      def create_type_file
        template "object.erb", "#{options[:directory]}/types/#{type_file_name}.rb"
      end
    end
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
graphql-1.8.15 lib/generators/graphql/object_generator.rb
graphql-1.9.0.pre4 lib/generators/graphql/object_generator.rb
graphql-1.8.14 lib/generators/graphql/object_generator.rb
graphql-1.9.0.pre3 lib/generators/graphql/object_generator.rb
graphql-1.9.0.pre2 lib/generators/graphql/object_generator.rb
graphql-1.8.13 lib/generators/graphql/object_generator.rb
graphql-1.8.12 lib/generators/graphql/object_generator.rb
graphql-1.9.0.pre1 lib/generators/graphql/object_generator.rb
graphql-1.8.11 lib/generators/graphql/object_generator.rb
graphql-1.8.10 lib/generators/graphql/object_generator.rb
graphql-1.8.9 lib/generators/graphql/object_generator.rb
graphql-1.8.8 lib/generators/graphql/object_generator.rb
graphql-1.8.7 lib/generators/graphql/object_generator.rb
graphql-1.8.6 lib/generators/graphql/object_generator.rb
graphql-1.8.5 lib/generators/graphql/object_generator.rb
graphql-1.8.4 lib/generators/graphql/object_generator.rb
graphql-1.8.3 lib/generators/graphql/object_generator.rb
graphql-1.8.2 lib/generators/graphql/object_generator.rb
graphql-1.8.1 lib/generators/graphql/object_generator.rb
graphql-1.8.0 lib/generators/graphql/object_generator.rb