Sha256: 0fd2a73dfd8f805aed8d40d4e1a457cfd9ebe54505fd5359786b46cc1ef44253

Contents?: true

Size: 934 Bytes

Versions: 28

Compression:

Stored size: 934 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", "app/graphql/types/#{type_file_name}.rb"
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
graphql-1.7.4 lib/generators/graphql/object_generator.rb
graphql-1.7.3 lib/generators/graphql/object_generator.rb
graphql-1.7.2 lib/generators/graphql/object_generator.rb
graphql-1.7.1 lib/generators/graphql/object_generator.rb
graphql-1.7.0 lib/generators/graphql/object_generator.rb
graphql-1.6.8 lib/generators/graphql/object_generator.rb
graphql-1.6.7 lib/generators/graphql/object_generator.rb
graphql-1.6.6 lib/generators/graphql/object_generator.rb
graphql-1.6.5 lib/generators/graphql/object_generator.rb
graphql-1.6.4 lib/generators/graphql/object_generator.rb
graphql-1.5.15 lib/generators/graphql/object_generator.rb
graphql-1.6.3 lib/generators/graphql/object_generator.rb
graphql-1.6.2 lib/generators/graphql/object_generator.rb
graphql-1.6.1 lib/generators/graphql/object_generator.rb
graphql-1.6.0 lib/generators/graphql/object_generator.rb
graphql-1.5.14 lib/generators/graphql/object_generator.rb
graphql-1.5.13 lib/generators/graphql/object_generator.rb
graphql-1.5.7.1 lib/generators/graphql/object_generator.rb
graphql-1.5.12 lib/generators/graphql/object_generator.rb
graphql-1.5.11 lib/generators/graphql/object_generator.rb