class Graphql::Generators::ObjectGenerator

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

“‘ rails g graphql:object PostType name:String! “`

Add the Node interface with ‘–node`.

Public Class Methods

normalize_type_expression(type_expression, mode:, null: true) click to toggle source
Calls superclass method
# File lib/generators/graphql/object_generator.rb, line 26
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/object_generator.rb, line 45
def graphql_type
  "object"
end