class Graphql::Generators::InputGenerator

Generate an input type by name, with the specified fields.

“` rails g graphql:object PostType name:string! “`

Public Class Methods

normalize_type_expression(type_expression, mode:, null: true) click to toggle source
Calls superclass method
# File lib/generators/graphql/input_generator.rb, line 18
def self.normalize_type_expression(type_expression, mode:, null: true)
  case type_expression.camelize
  when "Text", "Citext"
    ["String", null]
  when "Decimal"
    ["Float", null]
  when "DateTime", "Datetime"
    ["GraphQL::Types::ISO8601DateTime", null]
  when "Date"
    ["GraphQL::Types::ISO8601Date", null]
  when "Json", "Jsonb", "Hstore"
    ["GraphQL::Types::JSON", null]
  else
    super
  end
end

Private Instance Methods

graphql_type() click to toggle source
# File lib/generators/graphql/input_generator.rb, line 37
def graphql_type
  "input"
end
type_file_name() click to toggle source
Calls superclass method
# File lib/generators/graphql/input_generator.rb, line 45
def type_file_name
  super.gsub(/_type\z/, "_input_type")
end
type_ruby_name() click to toggle source
Calls superclass method
# File lib/generators/graphql/input_generator.rb, line 41
def type_ruby_name
  super.gsub(/Type\z/, "InputType")
end